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的倍数的,以此类推...最后问你有几个监狱是打开的 题目中我使用了 ...
随机推荐
- 理解 Linux 的硬链接与软链接(待研究)
从 inode 了解 Linux 文件系统 硬链接与软链接是 Linux 文件系统中的一个重要概念,其涉及文件系统中的索引节点 (index node 又称 inode),而索引节点对象是 Linux ...
- js实现ctrl+v粘贴图片或是截图
浏览器环境:谷歌浏览器 1.ctrl+v粘贴图片都是监听paste时间实现的,复制的数据都存在clipboardData下面,虽然打印显示数据长度为0,但是还是可以获取数据的 2.打印clipboar ...
- Python匿名函数详解
python 使用 lambda 来创建匿名函数. lambda这个名称来自于LISP,而LISP则是从lambda calculus(一种符号逻辑形式)取这个名称的. 在Python中,lambda ...
- java基础65 JavaScript中的Window对象(网页知识)
1.javaScript组成部分 1.EMCAScript(基本语法) 2.BOM(Browser Object Model):浏览器对象模型 浏览器对象模型中的浏览器的各 ...
- Oracle 函数 “数据控制,指定某些人只能查看他权限范围内的信息”
create or replace function work_plan_mask (p_schema VARCHAR2,p_table VARCHAR2) return Varchar2 AS -- ...
- Elasticsearch 邻近查询示例
Elasticsearch 邻近查询示例(全切分分词) JAVA API方式: SpanNearQueryBuilder span = QueryBuilders.spanNearQuery(); s ...
- activiti源码分析学习
activiti源码分析学习导语 目前项目中用activiti来做工作流的相关工作,最近遇到一些情况下,公司二次开发的流程图渲染出现了问题,会造成流程图出不来的情况.初步分析数据库中记录以及简单的代码 ...
- 【[SDOI2009]Bill的挑战】
一看题解好像全是状压DP,那么我就来补充一个容斥写法吧 乍一看,好像是水题,枚举选哪k个串,然后判断 1,如果这k个串中至少两个串某位置确定且不相同,答案显然为02,如果这个位置只被有且仅有一个串确定 ...
- CF529B 【Group Photo 2 (online mirror version)】
贪心枚举最后方案中最大的h,设为maxh若某个人i的wi与hi均大于maxh,则此方案不可行若某个人恰有一个属性大于maxh,则可确定他是否换属性剩下的人按wi-hi从大到小排序后贪心选择O(nlog ...
- java jps命令使用解析
在linux环境下显示一个进程的信息大家可能一直都在使用ps命令,比如用以下命令来显示当前系统执行的java进程: ps -ef | grep java 针对java的进程,jdk1.5以后提供了一个 ...