<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. Windows Server 2012启用Windows功能NetFx3时出错解决方法

    作者:冰点阳光 | 可以转载, 但必须以超链接形式标明文章原始出处和作者信息及版权声明网址:http://baohua.me/operating-system/windows-server-2012- ...

  2. AsyncTask測试多任务

    本人进行过模拟測试,发现AsyncTask并不适合多任务,以及长期的异步任务,由于每次仅仅能执行一个AsyncTask,假设执行多个其他任务将会等待 以下通过一个代码样例和日志打印得到证实. 以下扩展 ...

  3. SQL优化策略高级优化经常使用-1(The Return Of The King)

    1 经常使用的优化策略 1.1    语句 1.1.1使用实际的列名 当我们查询SQL语句时.你是否觉得使用实际的列名比使用*更快呢?答案是肯定的. 为了证实这一点,感兴趣的朋友能够自己验证一下.我这 ...

  4. (hdu step 7.1.5)Maple trees(凸包的最小半径寻找掩护轮)

    称号: Maple trees Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Tot ...

  5. T-SQL技巧收集——拆分字符串

    原文:T-SQL技巧收集--拆分字符串 在开发中,很多时候都需要处理拆分字符串的操作.下面收集了几种方法供大家分享,其中的逗号可以改为多种有需要的符号,但是不能针对多种符号同时存在的例子.有待各位补充 ...

  6. 走向DBA[MSSQL篇] 详解游标

    原文:走向DBA[MSSQL篇] 详解游标 前篇回顾:上一篇虫子介绍了一些不常用的数据过滤方式,本篇详细介绍下游标. 概念 简单点说游标的作用就是存储一个结果集,并根据语法将这个结果集的数据逐条处理. ...

  7. [linux]scp指令(转)

    Linux scp命令用于Linux之间复制文件和目录,具体如何使用这里好好介绍一下,从本地复制到远程.从远程复制到本地是两种使用方式.这里有具体举例: ================== Linu ...

  8. 并发队列ConcurrentLinkedQueue和阻塞队列LinkedBlockingQueue用法(转)

    在Java多线程应用中,队列的使用率很高,多数生产消费模型的首选数据结构就是队列(先进先出).Java提供的线程安全的Queue可以分为阻塞队列和非阻塞队列,其中阻塞队列的典型例子是BlockingQ ...

  9. 《Effective C++》:规定44-规定45

    规定44分离的不依赖参数代码templates 条款45运用成员函数模板接受全部兼容类型 Templates和泛型编程 条款44:将与參数无关的代码抽离templates Templates能够节省时 ...

  10. JavaScript权威指南科13章 webj浏览器avascript

    13.1 clientjavascript window对象是所有clientjavascript特点和api主要的接入点.它代表了一个浏览器窗口,通过window对象引用它. window 方法 a ...