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. C#基础加强

    1.代码规范 -命名规范:定义的变量或者方法名要有意义. 1.骆驼命名 :第一个单词首字母小写,之后的单词首字母大写 userName.userPassword.realName…(普通变量(局部变量 ...

  2. oracle学习笔记4:PL/SQL

    PL/SQL是没命名的存储过程,函数,触发器,PL/SQL块的语法格式如下: [declare] --声明部分,可选 begin --执行部分,必须 [exception] --异常处理部分,可选 e ...

  3. AUTOTRACE Statistics常用列解释

    AUTOTRACE Statistics常用列解释 序号 列名 解释 1 db block gets 从buffer cache中读取的block的数量 2 consistent gets 从buff ...

  4. DBA 培训相应内容笔记

    014-12-23 slow hang lock 三种常见性能问题 hang;整个数据库不响应,无法创建新连接. hanganalyze输出. dump文件是否有问题信息, 文件是否有其他信息 工具: ...

  5. tomcat上servlet程序的配置与处理servlet请求过程

    手动配置: tomcat服务器下web项目的基本目录结构 |-tomcat根目录 |-webapps |-WebRoot : web应用的根目录 |-静态资源(html+css+js+image+ve ...

  6. java 反射取得方法入参类型的泛形

    package TestReflectClass; import java.util.List; /** * Created by wangyang on 2016/12/16. */ public ...

  7. 输出第N个素数

    输出第N个素数 public class FindNthPrime { public static void main(String[] args){ int N = Integer.parseInt ...

  8. 子元素增加margin-top会增加给父元素的问题

    假设我们有如下代码 <div id="father" style="height:400px;width:400px;background:#e4393c;&quo ...

  9. PHP实现简易的模板引擎

    PHP实现简易的模板引擎 1.MVC简介 MVC 是一种使用 MVC(Model View Controller 模型-视图-控制器)设计创建 Web 应用程序的模式(详情自己百度): 1. Mode ...

  10. PHP页面静态化入门

    <?php /** *PHP页面静态化分为以下步骤: *1.打开输出控制缓存 *2.返回输出缓存区的内容 *3.将一个字符串写入文件 *4.冲刷出缓存区的内容 */ //1.打开输出控制缓存 o ...