3221225620错误
查看原帖
3221225620错误
565378
Orange1015楼主2021/12/12 11:45

为什么代码运行时会return with value 3221225620?

#include<bits/stdc++.h>
using namespace std;
long long gcd(long long a,long long b){
	if(a%b==0) return b;
	return (b,a%b);
}
long long lcm(long long a,long long b){
	return a*b/gcd(a,b);
}
int main(){
	long long p=1,q,x,y,ans=0;
	cin >> x >> y;
	while(p<q){
		if((x*y)%p==0)q=x*y/p;
		else continue;
		if(gcd(p,q)==x&&lcm(p,q)==y) ans+=2;
		p++;
	}
	if(gcd(p,q)==x&&lcm(p,q)==y)
		ans++;
	cout << ans;
} 
2021/12/12 11:45
加载中...