Hangzhou Electric 1795 The least one

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.