社区讨论
70求调,改对必关(*^▽^*)
P1029[NOIP 2001 普及组] 最大公约数和最小公倍数问题参与者 3已保存回复 3
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 3 条
- 当前快照
- 1 份
- 快照标识符
- @mhj0g8tt
- 此快照首次捕获于
- 2025/11/03 18:42 4 个月前
- 此快照最后确认于
- 2025/11/03 18:42 4 个月前
CPP
#include<bits/stdc++.h>
using namespace std;
long long gcd(long long a,long long b) {
return !b?a:gcd(b,a%b);
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
long long x0,y0,P,Q,s=0;
cin>>x0>>y0;
if(y0%x0) cout<<0;
else {
for(P=1; P<=sqrt(x0*y0); P++) {
Q=x0*y0/P;
if(P*Q==x0*y0&&x0==gcd(P,Q)) s+=2;
}
if(P==Q) s--;
cout<<s;
}
return 0;
}
回复
共 3 条回复,欢迎继续交流。
正在加载回复...