<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. Apple Watch开发了一些细节和总结

    本文旨在总结最近Watch在发展中遇到的问题和细节 1.左右Watch真机调试问题 一般的情况下,你为IOS主应用创建了一个extention,比方说Today Extension .Xcode都会自 ...

  2. Java多线程&lt;1&gt;

    1.Java多线程的概念: 线(Thread):它指的是一个任务的从开始执行流程到结束. 穿线提供执行任务的机构.供java条款.在一个程序可以启动多个并发线程.候执行. 在单处理器系统中,多个线程共 ...

  3. Cocos2d-Java安装和配置跨平台游戏引擎以及相关的开发工具

    假设认为博文图片不清晰.能够Ctrl+鼠标滚动缩放网页比例 Cocos2d-Java是什么? http://blog.csdn.net/touchsnow/article/details/387047 ...

  4. 移动端 new CustomEvent('input') 兼容问题

    最近在 安卓自带浏览器 上发现  new CustomEvent('input') 不兼容 解决办法 (function () { if(!!window.CustomEvent) return; f ...

  5. IOS-Plist文件存储(1)

    1.什么是一个文件系统? IOS每个应用程序都有自己的文件系统.并且有一个相应的接入,一般分 ~/Documents/ ~/tmp/ ~/Library/Caches/ ~/Library/Prefe ...

  6. ASP.NET MVC:01理解MVC模式

    ASP.NET MVC是ASP.NET Web应用程序框架,以MVC模式为基础. MVC:Model View Controller 模型-视图-控制器Model(模型):负责对数据库的存取View( ...

  7. 实例教程Unity3D单例模式(一)通经常使使用方法

    unity3d教程 中的单例模式通经常使使用方法 通经常使使用方法是在相关类增加GetInstance()的静态方法,检查实例是否存在.假设存在,则返回.假设不存在.则返回一个"须要用游戏元 ...

  8. Team Foundation Server 2015使用教程--团队项目创建

  9. cocos2d-x3.0 windows 环境配置

    cocos2d-x3.0 windows 环境配置 参考Oo泡泡糖oO的CSDN博文 :http://blog.csdn.net/u010296979/article/details/24273393 ...

  10. hdu 5076 最小割灵活运用

    这意味着更复杂的问题,关键的事实被抽象出来:每个点,能够赋予既有的值(挑两个一.需要选择,设定ai,bi). 寻找所有和最大.有条件:如果两个点同时满足: 1,:二进制只是有一个不同之处.  2:中的 ...