这题搞法很多,写个枚举因子的模版放在这里,另有用处。
typedef long long LL;
const int maxn = 10008 ;
bool is[maxn] ;
int ps ;
int prime[maxn] ;
void make(){
memset(is , 0 , sizeof(is)) ;
ps = 0 ;
for(int i = 2 ; i < maxn ; i++){
if(! is[i]) prime[ps++] = i ;
for(int j = 0 ; j < ps && i * prime[j] < maxn ; j++){
is[i * prime[j]] = 1 ;
if(i % prime[j] == 0) break ;
}
}
}
vector< pair<int , int> > plis ;
void get_pfactor(LL n){
plis.clear() ;
for(int i = 0 ; i < ps && prime[i] * prime[i] <= n ; i++){
if(n % prime[i] == 0){
int c = 0 ;
while(n % prime[i] == 0){
c++ ;
n /= prime[i] ;
}
plis.push_back(make_pair(prime[i] , c * 2)) ;
}
}
if(n != 1) plis.push_back(make_pair(n , 2)) ;
}
LL Pow(LL x , LL y){
LL s = 1 ;
for(; y ; y >>= 1){
if(y & 1) s *= x ;
x *= x ;
}
return s ;
}
vector<LL> factor ;
void dfs(LL f , int id){
if(id >= plis.size()){
factor.push_back(f) ;
return ;
}
for(int i = 0 ; i <= plis[id].second ; i++){
dfs(f * Pow(plis[id].first , i) , id+1) ;
}
}
LL ans(LL n){
get_pfactor(n) ;
factor.clear() ;
dfs(1 , 0) ;
sort(factor.begin() , factor.end()) ;
LL t = 0 ;
for(int i = 0 ; i < factor.size() ; i++){
LL x = factor[i] ;
LL y = n * n / factor[i] ;
if(x <= y) t++ ;
}
return t ;
}
int main(){
make() ;
LL n ; int t , T = 1 ;
cin>>t ;
while(t--){
cin>>n ;
printf("Scenario #%d:\n" , T++) ;
cout<< ans(n) << endl ;
puts("") ;
}
return 0 ;
}