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<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int main(){
int n,t;
cin>>t;
while(t--){
int ans=0;
cin>>n;
int a[n];
memset(a,0,sizeof(a));
for(int i=0;i<n;i++){
for(int j=i;j<n;j+=(i+1)){
if(!a[j]){
a[j]=1;
}
else{
a[j]=0;
}
}
}
for(int i=0;i<n;i++){
if(a[i]){
ans++;
}
}
cout<<ans<<endl;
}
return 0;
}