dumn2011man @ 2024-06-15 08:12:11
#include<bits/stdc++.h>
using namespace std;
int gcd(int m,int n){
if(n==0) return m;
int c;
while(m%n!=0){
c=m%n;
m=n;
n=c;
}
return n;
}
int main(){
int x,y,cnt=0;
cin>>x>>y;
for(int i=x;i<=sqrt(x*y);i++){
if(x*y%i==0&&gcd(i,x*y/i)==x) cnt++;
}
cnt*=2;
int m=sqrt(x*y);
if(m*m==x*y){
cnt-=1;
}
cout<<cnt;
return 0;
}
为什么测试点三错了!!!
by rimen @ 2024-06-22 20:59:54
#include<bits/stdc++.h>
using namespace std;
long long x,y,sum=0;
int gcd(int a,int b){
if(!b) return a;
return gcd(b,a%b);
}
int main(){
cin>>x>>y;
for(int i=x;i<=y;i+=x){
if(gcd(i,x*y/i)==x&&(x*y)%i==0)sum++;
}
cout<<sum;
return 0;
}
你看这行吗??