<span style="background-color: rgb(204, 204, 204);">/*
A - THE DRUNK JAILER
Time Limit:1000MS Memory Limit:10000KB 64bit IO Format:%I64d & %I64u
Submit Status Practice POJ 1218
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 <span style="color:#6633ff;">the</span> number of prisoners that escape when the prison has n cells.
Sample Input
2
5
100
Sample Output
2
10
By Grant Yuan
2014.7.11
*/
#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std;
bool a[101];
int main()
{int m,n,i,j,sum=0;
cin>>n;
while(n--){memset(a,0,101);
cin>>m;
for(i=1;i<=m;i++)
for(j=1;j<=m;j++)
if(j%i==0) a[j]=1-a[j];
for(j=1;j<=m;j++)
if(a[j]) sum++;
cout<<sum<<endl;
sum=0;
}
return 0; }
</span>

Pku1218的更多相关文章

随机推荐

  1. “MEAN”技术栈开发web应用

    “MEAN”技术栈开发web应用 上一篇我们讲了如何使用angular搭建起项目的前端框架,前端抽象出一个service层来向后端发送请求,后端则返回相应的json数据.本篇我们来介绍一下,如何在no ...

  2. xsd的解释说明

    schema教程 XML Schema是以XML语言为基础的,它用于可替代DTD.一份XML schema文件描写叙述了XML文档的结构XML Schema语言也被称为XML Schema Defin ...

  3. unity3d 各功能的运行秩序,打回来,订购,的次数

    Update 当MonoBehaviour启用时,其Update在每一帧被调用. 仅调用一次(每帧) LateUpdate 当Behaviour启用时,  每帧调用一次: FixedUpdate 当M ...

  4. 前框 (一个)zTree 从数据库树形菜单动态加载

    这些天做动态菜单使用此插件.现在有一个非常广泛的开源框架,最新QUI框架是菜单部分使用这个插件开发,因此,它是非常值获取深入的研究和探讨,通过使用非常丰富的感觉功能,己开发和编写,官网上有非常详尽的A ...

  5. Oracle存储过程的简单示例

    ---创建一个表 create table TESTTABLE (   id1  VARCHAR2(12),   name VARCHAR2(32) ) select t.id1,t.name fro ...

  6. 一个ajax的Post要求

    <1> $.post(url,[data],[callback],[type]) 第一个参数是地址,第二个参数是一个参数传递.第三个参数是一个回调函数.參数是请求返回数据的类型 //一个a ...

  7. 普及windows流氓程序和监控软件

    win7下载更改后无黑屏windows7激活程序v1.0 一个立即安装 美女主播节目,和流行的色情垃圾邮件 安装程序,结果装了很多垃圾节目,输入.日历.文件等. 重新启动机器后,,会弹出广告. .他的 ...

  8. Java并发专题 带返回结果的批量任务执行 CompletionService ExecutorService.invokeAll(转)

    转载请标明出处:http://blog.csdn.net/lmj623565791/article/details/27250059 一般情况下,我们使用Runnable作为基本的任务表示形式,但是R ...

  9. hibernate学习笔记(1)hibernate基本步骤

    hibernate基本步骤 1.创hibernate置对象 Configuration config = newConfiguration(); config.configure("hibe ...

  10. 比列的数目更多,以便找到第一k小值

    问题叙述性说明:现有n作为一个有序序列(2,3,9),(3,5,11,23),(1,4,7,9,15,17,20),(8,15,35,9),(20,30,40),第k小值. 问题分析:可用多路归并排序 ...