0x32 约数
Hankson的趣味题 暴力枚举。。约数
#include<cstdio> #include<iostream> #include<cstring> #include<cstdlib> #include<algorithm> #include<cmath> using namespace std; int gcd(int a,int b) { if(a==0)return b; return gcd(b%a,a); } int lcm(int a,int b) { return a/gcd(a,b)*b; } int main() { int T; scanf("%d",&T); while(T--) { int a0,a1,b0,b1; scanf("%d%d%d%d",&a0,&a1,&b0,&b1); int ans=0; for(int i=1;i*i<=b1;i++) if(b1%i==0) { if(gcd(i,a0)==a1&&lcm(i,b0)==b1)ans++; if(i!=b1/i&&gcd(b1/i,a0)==a1&&lcm(b1/i,b0)==b1)ans++; } printf("%d\n",ans); } return 0; }
pain and happy in the cruel world.