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的倍数的,以此类推...最后问你有几个监狱是打开的 题目中我使用了 ...
随机推荐
- checkbox 全选和取消
//全选 $("#checkall").click(function () { if (this.checked) { //如果当前点击的多选框被选中 $('input[type= ...
- cobbler 无人值守系统安装
概述 本文适合centos6 | centos7 系统的安装 执行操作之前:检查系统防火墙,selinux是否关闭,网络链接是否畅通. Cobbler是一个免费开源系统安装部署软件,用于自动化网络安装 ...
- Python大数据处理案例
分享 知识要点:lubridate包拆解时间 | POSIXlt利用决策树分类,利用随机森林预测利用对数进行fit,和exp函数还原 训练集来自Kaggle华盛顿自行车共享计划中的自行车租赁数据,分析 ...
- 22 Gobs of data 设计和使用采集数据的包
Gobs of data 24 March 2011 Introduction To transmit a data structure across a network or to store it ...
- python基础--logging模块
很多程序都有记录日志的需求,并且日志中包含的信息即有正常的程序访问日志,还可能有错误.警告等信息输出,python的logging模块提供了标准的日志接口,你可以通过它存储各种格式的日志,loggin ...
- Python基础一(基本类型和运算符)
在说Python的基本类型钱我们先说下Python注释方式有哪几 Python注释 行注释 #行注释 行注释用以#开头,#右边的所有文字当做说明,而不是真正要执行的程序,起辅助说明作用 # 我是注释, ...
- Linux下的输入/输出重定向
Linux环境中支持输入输出重定向,用符号<和>来表示.0.1和2分别表示标准输入.标准输出和标准错误信息输出,可以用来指定需要重定向的标准输入或输出,比如 2>lee.dat 表示 ...
- 32 从1到n整数中1出现的次数
输入一个整数n,求从1到n这n个整数的十进制表示中1出现的次数. 主要思路:设定整数点(如1.10.100等等)作为位置点i(对应n的各位.十位.百位等等),分别对每个数位上有多少包含1的点进行分析 ...
- 结合Python代码介绍音符起始点检测 (onset detection)
本文由 meelo 原创,请务必以链接形式注明 本文地址 音符起始点检测介绍 音符起始点检测(onset detection)是音乐信号处理中非常重要的一个算法.节拍和速度(tempo)的检测都会基于 ...
- HTML5移动应用左右滑动touchmove touchmove touchend 实例
也是刚开始接触移动前端,大虾别喷 <!DOCTYPE HTML> <html> <head> <meta name="viewport" ...