标签:inf bit std stdio.h 根据 sam sample span int
3
这题我是自己打表发现的规律,但是对2和3不适用,然后就没多想就特判了一下.
1 #include <iostream> 2 #include <stdio.h> 3 #include <string.h> 4 #include <bits/stdc++.h> 5 using namespace std; 6 int pri(int x){ 7 if(x==2||x==3) 8 return 2; 9 int cnt=0;int ans=sqrt(x); 10 for(int i=1;i<ans;i++){ 11 if(x%i==0) 12 cnt++; 13 } 14 if(ans*ans==x) 15 cnt=cnt*2+1; 16 else 17 cnt=cnt*2; 18 return cnt; 19 } 20 int main(){ 21 int n; 22 scanf("%d",&n); 23 while(n--){ 24 int m; 25 scanf("%d",&m); 26 printf("%d\n",pri(m-1)); 27 } 28 return 0; 29 }
标签:inf bit std stdio.h 根据 sam sample span int
原文地址:http://www.cnblogs.com/zllwxm123/p/7351306.html