2017"百度之星"程序设计大赛 - 初赛(A) 小C的倍数问题

时间:2023-03-08 21:24:19

谢谢帮忙刷访问量!

题解当然下考再发啦

答案为P-1的约数个数

// It is made by XZZ
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
#define rep(a,b,c) for(rg int a=b;a<=c;a++)
#define drep(a,b,c) for(rg int a=b;a>=c;a--)
#define erep(a,b) for(rg int a=fir[b];a;a=nxt[a])
#define il inline
#define rg register
#define vd void
typedef long long ll;
il int gi(){
rg int x=0,f=1;rg char ch=getchar();
while(ch<'0'||ch>'9')f=ch=='-'?-1:f,ch=getchar();
while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
return x*f;
}
int main(){
int T=gi(),P,qt,ans;
while(T--){
P=gi()-1,qt=sqrt(P),ans=0;
rep(i,1,qt)if(P%i==0)ans+=2;
if(qt*qt==P)--ans;
printf("%d\n",ans);
}
return 0;
}