60分 6AC4RE求调
查看原帖
60分 6AC4RE求调
1179906
hhy8399楼主2024/8/23 23:57
#include <bits/stdc++.h>
using namespace std;

int x,y,ans;
int pd[10000][10000];

int lcm(int a, int b)
{
	int temp = a * b;
	temp = temp / __gcd(a, b);
	return temp;
}

int main()
{
	cin >> x >> y;
	for(int i = 1;i <= y;i++)
	{
		for(int j = 1;j <= y;j++)
		{
			if(pd[j][i] == 2)
			{
				ans ++;
				continue;
			}
			if(__gcd(i,j) == x && lcm(i,j) == y)
			{
				ans ++;
				pd[i][j] = 2;
				continue;
			}
			pd[i][j] = 1;
		}
	}
	cout << ans << endl;
	return 0;
}
2024/8/23 23:57
加载中...