The least one
Time limit:9000/3000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 492 Accepted Submission (s): 184
Problem Description in the RPG game ' go back Ice Age ' (I decide to develop the game after my undergraduate education), all Heros has their own respected value, and the skill of killing monsters is defined as the following rule:one hero can Ki LL the monstrers whose respected values is smaller then himself and the both respected values have none common factor but 1 , so the skill is the same as the number of the monsters he can kill. Now each kind of value of the monsters come. And your hero has to kill at least M ones. To minimize the damage of the battle, you should dispatch a hero with minimal respected value. Which hero would you dispatch? There is Q battles, in each battle, for I from 1 to Q, and your hero should kill Mi ones at least. You have all kind of heros with different respected values, and the values (heros ' and Monsters ') is positive.
Input the first line have one integer Q, then Q lines follow. In the Q lines there are an integer Mi, 0<q<=1000000, 0<mi<=10000.
Output for each case, there is Q results, in each result, you should output the value of the hero you'll dispatch to C Omplete the task.
Sample Input237
Sample Output511 Test Instructions: The nearest prime number that is larger than the given data
#include <stdio.h> #include <string.h> #define MAX 10010int su[max];void Prime () {int I,j;memset (su,0,sizeof (SU)); for (i=2;i<max;i++) {if (!su[i]) {for (j=i*2;j<max;j+=i) su[j]=1;}} Su[1]=1;} int main () {int t,n,m,j,i;scanf ("%d", &t);p rime (), while (t--) {scanf ("%d", &n), for (i=n+1;i<max;i++) {if (su[ i]==0) {printf ("%d\n", I); break;}}} return 0;}
Hangzhou Electric 1795 The least one