HDOJ-【1795 The least one】
来源:互联网 发布:日本经济现状 知乎 编辑:程序博客网 时间:2024/05/16 12:26
The least one
Time Limit: 9000/3000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 743 Accepted Submission(s): 304
Problem Description
In the RPG game “go back ice age”(I decide to develop the game after my undergraduate education), all heros have their own respected value, and the skill of killing monsters is defined as the following rule: one hero can kill the monstrers whose respected values are smaller then himself and the two respected values has 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 have to kill at least M ones. To minimize the damage of the battle, you should dispatch a hero with minimal respected value. Which hero will you dispatch ? There are 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’) are positive.
Input
The first line has one integer Q, then Q lines follow. In the Q lines there is an integer Mi, 0<Q<=1000000, 0<Mi<=10000.
Output
For each case, there are Q results, in each result, you should output the value of the hero you will dispatch to complete the task.
Sample Input
237
Sample Output
511
<span style="font-size:18px;">#include<cstdio>#include<cstring>int num[20000]; void primes(){int i,j;memset(num,0,sizeof(num));num[0]=num[1]=1; for(i=2;i<20000;++i){if(num[i])continue; for(j=i*2;j<20000;j+=i)num[j]=1;//非素数为 1} } int main(){int t;primes(); scanf("%d",&t);while(t--){int mi;scanf("%d",&mi);++mi;while(num[mi])++mi;printf("%d\n",mi); } return 0;}</span>
0 0
- hdoj 1795 The least one
- HDOJ-【1795 The least one】
- hdoj 1795 The least one 【简单题】
- HDOJ 题目1795 The least one(水题)
- HDOJ 1795 The least one(素数打表)
- hdu 1795 The least one
- 【HDU】 1795 The least one
- HDOJ 1795 The least one (大于一个数的最小素数) 打表
- HDU 1795--The least one【二分 || 暴力】
- 1795 The least one【素数打表】
- HDU杭电1795 The least one
- HDU 1795 The least one【二分】
- The least one
- HPU-ACM暑期培训第2周14级个人赛:Problem I The least one HDU 1795
- HDOJ 4283 You Are the One
- HDOJ 4283 You Are the One 题解
- Neither the JAVA_HOME nor the JRE_HOME environment variable is defined ;At least one of these enviro
- HDOJ 1009 Least CommonMultiple
- 在Sql中使用Try Catch
- web安全 应用表单密码类型输入启用了自动完成操作
- JQuery学习笔记之滑动显示和隐藏
- httpclient demo
- I2C
- HDOJ-【1795 The least one】
- 集成学习-adaboost,bagging,随机森林
- 数据库字符串拼接
- Linux 定时删除文件或文件夹的shell脚本
- Android 不可横向滑动的ViewPager的实现代码
- webview 加载html
- Intent(简单介绍)
- zxing简介与核心库编译
- iOS - 使用AFNetworking进行图片上传