THE DRUNK JAILER | ||||||
| ||||||
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. | ||||||
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 |
#include<stdio.h>
#include<string.h>
int a[106];
void solve(void)
{
int t;
scanf("%d",&t);
while(t--)
{
int n;
scanf("%d",&n);
memset(a,0,sizeof(a));
for(int i = 1 ; i <= n ; i++)
{
for(int j = 1 ; j <= n ; j++)
{
if(j%i==0)
{
if(a[j]==0) a[j] = 1;
else a[j] = 0;
}
}
}
int ans = 0;
for(int i = 1 ; i <= n ; i++) if(a[i]==1) ans++;
printf("%d\n",ans);
}
}
int main(void)
{
solve();
return 0;
}