__CrossBow_EXE__ @ 2023-07-24 16:43:40
30分 、
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,m,ans=0;
cin>>n>>m;
for(int i=m;i<=n;i++){
int j=n*m/i;
if(__gcd(i,j)==n&&i*j/__gcd(i,j)==m) ans++;
}
cout<<ans;
return 0;}
by MEGA_V @ 2023-07-24 16:57:09
for循环因该是n到m不是m到n
by 13245zy @ 2023-07-24 16:59:32
你的上限应该是ceil ( sqrt ( x * y ) ) ,而不是n
by 13245zy @ 2023-07-24 17:00:40
for循环因该是n到ceil ( sqrt ( x * y ) )
by 13245zy @ 2023-07-24 17:02:19
for 循环里面
int j;
if(y%i==0){
j=(x * y)/i;
if(__gcd(i,j)==x){
sum+=2;
if(i==j) sum--;
}
}
by 13245zy @ 2023-07-24 17:02:38
@13589109859jiyunhao
by 13245zy @ 2023-07-24 17:03:21
如果你感谢我,就加个关注吧。