P1029 80分help!!!
查看原帖
P1029 80分help!!!
948216
ZackofZHOU楼主2023/7/12 15:49

蒟蒻开了氧气,80分

//代码
#include<iostream>
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b)
{
    if(b == 0)
        return a;
    return gcd(b,a % b);
}
int main()
{
    int a,b,ans = 0,num = 0;
    cin >> a >> b;
    if(a == b)
    {
        cout << 1;
        return 0;
    }
	for(int i = 1;i <= b;i++)
	{
	    for(int j = i + 1;j <= b;j++)
	        if(i * j == a * b && gcd(i,j) == a)
	            ans++;
	}
	cout << ans * 2;
    return 0;
}
2023/7/12 15:49
加载中...