博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
poj 1218 THE DRUNK JAILER
阅读量:4968 次
发布时间:2019-06-12

本文共 2057 字,大约阅读时间需要 6 分钟。

THE DRUNK JAILER
Time Limit: 1000MS   Memory Limit: 10000K
Total Submissions: 23358   Accepted: 14720

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 the number of prisoners that escape when the prison has n cells.

Sample Input

25100

Sample Output

210

Source

1 #include
2 #include
3 #include
4 #include
5 #include
6 #include
7 #include
8 #include
9 #include
10 #include
11 #include
12 #include
13 #include
14 using namespace std;15 int main() 16 { 17 int n,i,j,k,a,count,counter; 18 scanf("%d",&n); 19 for(i=1;i<=n;i++) 20 { 21 counter=0; 22 scanf("%d",&a); 23 for(k=1;k<=a;k++) 24 { 25 count=0; 26 for(j=1;j<=a;j++) 27 if(k%j==0) 28 count++;29 if(count%2!=0) 30 counter++;31 } 32 printf("%d\n",counter); 33 } 34 return 0;35 }
View Code

 

转载于:https://www.cnblogs.com/qscqesze/p/3880172.html

你可能感兴趣的文章
HDU6203 ping ping ping
查看>>
《人人都是产品经理》书籍目录
查看>>
如何在git bash中运行mysql
查看>>
OO第三阶段总结
查看>>
构建之法阅读笔记02
查看>>
DataTable和 DataRow的 区别与联系
查看>>
检索COM 类工厂中CLSID 为 {00024500-0000-0000-C000-000000000046}的组件时失败
查看>>
mysql数据库中数据类型
查看>>
Fireworks基本使用
查看>>
Linux 标准 I/O 库
查看>>
.net Tuple特性
查看>>
Java基础常见英语词汇
查看>>
nginx启动、关闭命令、重启nginx报错open() "/var/run/nginx/nginx.pid" failed
查看>>
BZOJ 3097 Hash Killer I
查看>>
UINavigationController的视图层理关系
查看>>
html阴影效果怎么做,css 内阴影怎么做
查看>>
宏观经济
查看>>
综合练习:词频统计
查看>>
BZOJ1026: [SCOI2009]windy数
查看>>
样板操作数
查看>>