2018 Jingdong Written Exam

Relatively speaking, the difficulty of JD.com is a bit high. Compared with NetEase, it is a lot higher. Generally speaking, I only need to write one question, and the pass rate should not be too low. However, I feel that the first question still has ideas. Others The two questions are completely out of ideas, so let's write the first question today.

The first problem prints the smallest number that can be rounded up by all integers less than or equal to n
This question seems to me to be a relatively simple question. The first reaction to seeing the question is that all numbers are divisible, then multiplying all the numbers to get the result is not enough. However, this is not the case. For example, between 1 and 6 There are 4 abnormal points in between, and the abnormal point is the number that can be divisible by the previous number, and after multiplying it, it will increase the value of the result, so it is necessary to eliminate the abnormal point, and the solution of the problem becomes the output of 1 to All prime numbers between n are multiplied. After understanding the meaning of the question, it is not difficult to solve it later:
 
 
#include<iostream>
using namespace std; long MinInt(long a){ if(a==0) return 0; long i=1; for(long j=1;j<=a;j++){ int flag=0; if(j>3) for(int k=2;k<j;k++){ if(j%k==0) flag=1; } if(flag) continue; else i=i*j; } return i%987654321; } int main(){ long a; while(cin>>a){ cout<<MinInt(a)<<endl; } return 0; }

However, I don't know why, although it doesn't seem like a big problem, I can still only overwrite it by 10%. I don't know if I have missed something. I feel that the answers of several cases tested locally are still correct, so I am very confused. Also, there is still 1 hour and 10 minutes in the exam time after writing this question, but the last two questions are completely impossible to start, and humiliating handed in one hour later. . . As for the other two questions, if you are interested, you can try to solve them yourself.

Question 2 Enter a string. Remove 0 or more characters from the string, and determine the number of methods that can form a palindrome. Among them, "ABA", "A", etc. are all palindromes.
example
Input "ABA" output 5
Input "AAB" Output 4
It felt like looking for a pattern, but I didn't find any pattern.
The third question is the horse walking day problem, looking for the number of ways that the horse walking day can reach a certain point on the chessboard. It feels a bit like a derivative problem of the robot walking grid in the "Programmer Interview Golden Code". Unfortunately, I haven't seen it yet, so Sorry it won't. . . .
 
Well, in general, it is very difficult. I wish you success in the next round of written test.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325848111&siteId=291194637