poj 1218 THE DRUNK JAILER
Time Limit: 1000MS | Memory Limit: 10000K | |
Total Submissions: 23358 | Accepted: 14720 |
Description
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
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
Sample Input
2
5
100
Sample Output
2
10
Source
#include<iostream>
#include<string.h>
#include<stdio.h>
#include<ctype.h>
#include<algorithm>
#include<stack>
#include<queue>
#include<set>
#include<math.h>
#include<vector>
#include<map>
#include<deque>
#include<list>
using namespace std;
int main()
{
int n,i,j,k,a,count,counter;
scanf("%d",&n);
for(i=;i<=n;i++)
{
counter=;
scanf("%d",&a);
for(k=;k<=a;k++)
{
count=;
for(j=;j<=a;j++)
if(k%j==)
count++;
if(count%!=)
counter++;
}
printf("%d\n",counter);
}
return ;
}
poj 1218 THE DRUNK JAILER的更多相关文章
- poj 1218 THE DRUNK JAILER【水题】
THE DRUNK JAILER Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 25124 Accepted: 1576 ...
- [ACM] POJ 1218 THE DRUNK JAILER (关灯问题)
版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/sr19930829/article/details/37727417 THE DRUNK JAILE ...
- POJ 1218 THE DRUNK JAILER(类开灯问题,完全平方数)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2188 题目大意:n为5-100之间的一个数,代表有多少间牢房,刚开始所有房间打开,第一轮2的倍数的房间 ...
- THE DRUNK JAILER 分类: POJ 2015-06-10 14:50 13人阅读 评论(0) 收藏
THE DRUNK JAILER Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 24918 Accepted: 1563 ...
- HDU 1337 && POJ 1218&& zju 1350 方法总结
题目链接http://acm.hdu.edu.cn/showproblem.php?pid=1337 杭电 http://poj.org/problem?id=1218清华 http://acm.zj ...
- THE DRUNK JAILER
http://poj.org/problem?id=1218 题意:门的状态有两种开或关,初始化为开,每次进行状态转换,第一次把门号是1的倍数的门状态转换,第二次把门号是2的倍数的门状态转换,.... ...
- 2076. The Drunk Jailer
Problem A certain prison contains a long hall of n cells, each right next to each other. Each cell h ...
- Poj1218_THE DRUNK JAILER(水题)
一.Description A certain prison contains a long hall of n cells, each right next to each other. Each ...
- ZOJ Problem Set - 1350 The Drunk Jailer ac代码 memset
这是一道很简单的题目,题目大概意思说下:就是有n个监狱(编号从1到n),第一次全部打开,第二次打开编号为2的倍数的,第三次打开编号为3的倍数的,以此类推...最后问你有几个监狱是打开的 题目中我使用了 ...
随机推荐
- UrlRouteModule
一.请求流程 当一个请求发往ASP.net MVC站点时的情景,IIS收到请求并将请求转到ASP.net,然后根据URL,或者更确切来说:被请求文件的扩展名.在IIS7 integrated模式下(默 ...
- window.onload绑定多个事件 —— 两种解决方案
前言 有些函数,必须在网页加载完毕后执行.比如:涉及DOM操作的. 网页加载完毕时会触发一个onload事件,将函数绑定到这个事件上即可. window.onload = myFunction; 问题 ...
- Bootstrap FileInput中文API文档
Bootstrap FileInput中文API整理 这段时间做项目用到bootstrap fileinput插件上传文件,在用的过程中,网上能查到的api都不是很全,所以想着整理一份比较详细的文档, ...
- AdvStringGrid 删除数据
unit Unit6; interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System ...
- Effective STL 学习笔记14: Use reserve to avoid unnecessary reallocations.
vector 和 string 容器在动态插入一个新的对象时,如果容器内空间不够,该容器会: 重新分配空间 通常的做法是分配当前 Capacity 大小两倍的空间. 将旧空间中的所有元素拷贝进新的空间 ...
- SSIS 学习之旅 第一个SSIS 示例(二)
这一章还是继上一章例子 进行一些小的知识扩展.主要是为了让大家更快的上手SSIS. 概要设计: 1.按用户组生成CSV文件到Pending目录下, 2.移动Pending目录下的CSV文件 ...
- Owin 自定义中间件
/// <summary> /// 自定义的中间件 /// </summary> public class CustomMiddleware : OwinMiddleware ...
- Spring的配置文件ApplicationContext.xml配置头文件解析
Spring的配置文件ApplicationContext.xml配置头文件解析 原创 2016年12月16日 14:22:43 标签: spring配置文件 5446 spring中的applica ...
- C#一步一步学网络辅助开发(1)--常用抓包工具的使用
这次写的是一个系列,是让大家了解如何进行网络的辅助开发.要进行网络辅助开发抓包工具是必不可少的,下面就让大家熟悉一下常用的一些抓包工具, 1,Fiddler 这个工具是我目前用的最多的一款抓包工具,不 ...
- dubbo-demo的运行
在学习dubbo时,最主要的是将dubbo运行起来. 现在先搭建起来简单的demo. 一:安装zookeeper(在wondows下安装,且是单机模式) 1.下载zookeeper 2.下载的版本 3 ...