HDOJ 1795 The least one(素数打表)
来源:互联网 发布:非凡网络加速器 官网 编辑:程序博客网 时间:2024/06/05 16:59
The least one
Time Limit: 9000/3000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 449 Accepted Submission(s): 161
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
题目很水,但题目看不懂。赛后翻译,哭成狗。。。
题意说:在一个游戏中,英雄杀死怪物的条件有两个:1.英雄必须高于怪物的生命值;2.英雄与怪物的生命值除1之外没有其他公因数。 给出怪物生命值mi,找出最小的能击杀怪物的英雄的生命值,即找出大于mi的最小素数。
简单,代码如下:(不打表也能过)
#include<cstdio>#define max 11000int a[max]={1,1};void primes(){int i,j;for(i=2;i*i<=max;i++){if(a[i]) continue;for(j=i*i;j<max;j=j+i) a[j]=1;}}int main(){primes();int q,m,i;scanf("%d",&q);while(q--){scanf("%d",&m);for(i=m+1;;i++) if(!a[i]) break;printf("%d\n",i);}return 0;}
0 0
- HDOJ 1795 The least one(素数打表)
- 1795 The least one【素数打表】
- 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
- HDU 1795--The least one【二分 || 暴力】
- HDU杭电1795 The least one
- HDU 1795 The least one【二分】
- The least one
- hdoj 4548 美素数 【打表】
- hdoj 1431 素数回文 【暴力打表】
- HDOJ 4548 美素数(打表)
- hdoj--5104--Primes Problem(素数打表)
- hdoj 2012 素数判定 (打表)
- 用JavaScript验证表单
- 图片资源的平铺
- 开始,就现在
- 推特注册相关
- 笔试真题解析 TT-2014 研发笔试题
- HDOJ 1795 The least one(素数打表)
- php-高级(错误处理和异常处理)
- Android工作两年之后的第一个App--天真无谐
- .WORD作用
- win10优化大全
- Google 镜像站搜集
- 解决IE兼容问题的 条件编译和 条件注释
- Android-Universal-Image-Loader 图片异步加载类库的使用(超详细配置)
- 关于简单的加密和解密算法