这个监狱长还真是有点无聊。。。
最后开的门跟这个数的因数有关,因为一次开一次关。。所以只有因数个数为奇数的门最后是开的。。
而一个数的因数基本都是成对出现的,比如20的因数是1*20,2*10,4*5
只有完全平方数的因数个数是奇数个。。直接sqrt(n)就可以了。。
第一次在C++提交CE了。。换成G++就AC了。。
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
int nCase;
scanf("%d",&nCase);
while(nCase--){
int n;
scanf("%d",&n);
printf("%d\n",(int)sqrt(n));
}
return 0;
}