Problem  C

Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 20000/10000K (Java/Other)
Total Submission(s) : 9   Accepted Submission(s) : 8
Problem Description
A certain prison contains a long hall of n cells, each right next to each other. Each cell has a prisoner in it, and each cell is locked. One night, the jailer gets bored and decides to play a game. For round 1 of the game, he takes a drink of whiskey,and then runs down the hall unlocking each cell. For round 2, he takes a drink of whiskey, and then runs down the hall locking every other cell (cells 2, 4, 6, ?). For round 3, he takes a drink of whiskey, and then runs down the hall. He visits every third cell (cells 3, 6, 9, ?). If the cell is locked, he unlocks it; if it is unlocked, he locks it. He repeats this for n rounds, takes a final drink, and passes out. Some number of prisoners, possibly zero, realizes that their cells are unlocked and the jailer is incapacitated. They immediately escape. Given the number of cells, determine how many prisoners escape jail.
 
Input
The first line of input contains a single positive integer. This is the number of lines that follow. Each of the following lines contains a single integer between 5 and 100, inclusive, which is the number of cells n.
 
Output
For each line, you must print out the number of prisoners that escape when the prison has n cells.
 
Sample Input
2
5
100
 
Sample Output
2
10
#include<stdio.h>
#include<string.h>
int main()
{
int t,n,i,s,m,j,k;
scanf("%d",&t);
while(t--)
{
k=0;
scanf("%d",&n);
for(i=1;i<=n;i++)
{s=0;
for(j=1;j<=i;j++)
{
if(i%j==0)
s++;
}
if(s%2!=0)
k++;
}
printf("%d\n",k);
}
return 0;
}

POJ1218的更多相关文章

  1. poj-1218 THE DRUNK JAILER 喝醉的狱卒

    自己去看看原题; 题目大意: 就是一个狱卒喝醉了,他第一趟吧所有的监狱都带开,第二趟把能把二整除的监狱关闭,第三趟操作能把三整除的监狱; 求最后能逃跑的罪犯数 输入第一个数是代表 测试数据组数 每个数 ...

  2. ACM训练计划建议(写给本校acmer,欢迎围观和指正)

    ACM训练计划建议 From:freecode#  Date:2015/5/20 前言: 老师要我们整理一份训练计划给下一届的学弟学妹们,整理出来了,费了不少笔墨,就也将它放到博客园上供大家参考. 菜 ...

  3. 【POJ水题完成表】

    题目 完成情况 poj1000:A+B problem 完成 poj1002:电话上按键对应着数字.现在给n个电话,求排序.相同的归一类 完成 poj1003:求最小的n让1+1/2+1/3+...+ ...

  4. 11月下旬poj其他题

    poj1000,poj1003,poj1004,poj1064,poj1218 水题 poj1012:0<k<14——漂亮的打表 poj1651:与能量项链很像的dp poj1159:回文 ...

  5. ACM训练计划建议(转)

    ACM训练计划建议 From:freecode#  Date:2015/5/20 前言: 老师要我们整理一份训练计划给下一届的学弟学妹们,整理出来了,费了不少笔墨,就也将它放到博客园上供大家参考. 菜 ...

随机推荐

  1. 什么是JavaScript?

  2. CI框架篇之视图篇--载入(1)

    创建视图 创建视图文件很简单,只需要建立后缀名为‘.php’的文件, 然后保存文件到 application/views/ 文件夹即可 当然,随着工程的大小,你有必要对很多的视图根据控制器进行归类, ...

  3. C#磁盘遍历——递归

    static void Main(string[] args) { //创建秒表,记录查询的总时间 Stopwatch timer = new Stopwatch(); timer.Start(); ...

  4. Http请求通信(工具类)

    Http请求通信(工具类) 异步消息处理流程是: 首先需要在主线程当中创建一个Handle对象,并重写handlerMessage()方法. 然后当子线程中需要进行UI操作时,就创建一个Message ...

  5. asp.net - GridView根据linkButton值不同跳转不同页面

    一,当前页面中,前台界面的主要代码: <asp:TemplateField HeaderText="姓名"> <ItemTemplate> <!--根 ...

  6. window远程连接linux

    一.字符界面连接Linux    1.直接使用window自带的telnet. 2.但现在Linux一般都不启用telnet,而是启用ssh.这样的话,window就要安装客户端来访问Linux了.这 ...

  7. Linq XML

    写得比较啰嗦,自己记载备用   1 public class XmlFunction   2     {   3         private static XDocument _doc = new ...

  8. 速卖通api--获取商品信息

    <? $productId    = 'xxxx';//你的产品id    $access_token = 'xxxxx';//你的授权码    $appSecret    = 'xxxx';/ ...

  9. iOS 异常汇总

    reason: 'invalid nib registered for identifier (cell) - nib must contain exactly one top level objec ...

  10. 转载C#泛型集合—Dictionary<K,V>使用技巧

    1.要使用Dictionary集合,需要导入C#泛型命名空间 System.Collections.Generic(程序集:mscorlib) 2.描述 1).从一组键(Key)到一组值(Value) ...