The least one
来源:互联网 发布:python文本分析和提取 编辑:程序博客网 时间:2024/05/17 01:29
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
5
11
题意:找与Q离得最近的素数
#include<stdio.h>#include<math.h>#include<string.h>int is(int x){if(x==0||x==1)return 0;else{int c;c=sqrt(x*1.0);for(int i=2;i<=c;i++){if(x%i==0)return 0;//return 1;}return 1;} } int main(){int n;scanf("%d",&n);while(n--){int Q,i;scanf("%d",&Q);for(i=Q+1;;i++){if(is(i)){ printf("%d\n",i); break;} }}return 0;}
0 0
- 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【二分 || 暴力】
- hdoj 1795 The least one 【简单题】
- 1795 The least one【素数打表】
- HDU杭电1795 The least one
- HDU 1795 The least one【二分】
- HDOJ 题目1795 The least one(水题)
- HDOJ 1795 The least one(素数打表)
- Neither the JAVA_HOME nor the JRE_HOME environment variable is defined ;At least one of these enviro
- WCF分布式开发常见错误(14):无效的操作异常,At least one operation on the ...
- Entities exposed by DomainService operations must have at least one public property marked with the
- 上传苹果应用 At least one of the following architecture(s) must be present: armv6 (-19033)
- iPhone/iPod Touch: application executable is missing a required architecture. At least one of the fo
- Access denied; you need (at least one of) the RELOAD privilege(s) for this operation
- 局域网YUM源中添加rpm包
- ubuntu中装mysql
- 矩阵理解(三)
- 选取命令:cut,grep
- HDU1698 Just a Hook
- The least one
- android 中resources管理
- NYOJ 236 心急的c小加
- FZU 2187 回家种地(矩形面积并)
- IOS用CGContextRef画各种图形(文字、圆、直线、弧线、矩形、扇形、椭圆、三角形、圆角矩形、贝塞尔曲线、图片)
- Linux中查看CPU信息
- eclipes下NDK调试出现Unknown Application ABI:Unable to detect application ABI's错误的解决
- poj2038Fractal盒分形深搜递归
- ios 之 图片压缩 与剪切