当前位置: 首页 > 工具软件 > Jailer > 使用案例 >

B - THE DRUNK JAILER POJ - 1218

翟淮晨
2023-12-01

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

2
5
100

Sample Output

2

10

开关问题;现在给你n个灯泡,要你操作n次,开始时灯泡都是关闭的,当进行第i次操作时,把第j个灯泡的状态

改变,j是i的倍数。问最后有多少个灯泡亮的。

对于任意数,在该题中,对于每个数,他又多少个因子就要操作多少次,只有当操作的次数为奇数时最后才是亮的。而只有当某数满足开平方后为整数时他的因子才为奇数,即求1到n中能开平方后为整数的个数,即sqrt(n)个

 类似资料: