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的倍数的,以此类推...最后问你有几个监狱是打开的 题目中我使用了 ...
随机推荐
- 基于消逝时间量的共识机制(POET)
来自于Intel project:Hyperledger Sawtooth,目前版本 PoET 1.0 PoET 其实是属于Nakamoto consenus的一种,利用“可信执行环境”来提高当前解决 ...
- Jenkins关联GitHub进行构建
一.创建一个自由风格的项目 并在高级中勾选你构建完成后保存项目的路径 二.配置你存放代码的GitHub的地址并添加用户名密码 三.立即构建
- mysql -> 简介&体系结构_01
数据库简介 数据库,简而言之可视为电子化的文件柜——存储电子文件的处所,用户可以对文件中的数据运行新增.截取.更新.删除等操作. 所谓“数据库”系以一定方式储存在一起.能予多个用户共享.具有尽可能小的 ...
- orcale数据库分配用户
account lock:创建用户的时候锁定用户 account unlock:创建用户的时候解锁用户,默认该选项 create user zhou8–用户名 identified by zhou88 ...
- less常用样式集,清除浮动、背景自适应、背景渐变、圆角、内外阴影、高度宽度计算。
.clear-float() { content: ''; display: block; clear: both; height:; } //伪元素清除浮动 .after-clear() { &am ...
- ZooKeeper常见问题
转载自原文:zookeeper(二)常见问题汇总 一.为什么zookeeper要部署基数台服务器? 所谓的zookeeper容错是指,当宕掉几个zookeeper服务器之后,剩下的个数必须大于宕掉的个 ...
- 20155225 实验一《Java开发环境的熟悉》实验报告
20155225 实验一<Java开发环境的熟悉>实验报告 一.命令行下Java程序的开发 按照老师提供的步骤,运行程序如下: 二.IDEA下Java程序开发.调试 设置条件断点如下: 三 ...
- MP3 Fuzz学习
这篇文章主要是学习一波MP3格式fuzz的知识.目录如下 0x0.MP3格式的构成 0x0.MP3格式的构成 MP3是一种通俗叫法,学名叫MPEG1 Layer-3.MP3是三段式的结构,依次由ID3 ...
- 《精通Python设计模式》学习结构型之MVC模式
这个就不需要多评论了, 哪个主流的PYTHON的WEB框架都有这些模式实现哈. quotes = ('A man is not complete until he is married. Then h ...
- USACO 5.5 Twofive
TwofiveIOI 2001 In order to teach her young calvess the order of the letters in the alphabet, Bessie ...