Logo Wy Online Judge

WyOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#317#4. 「WyOJ Round 1」启 · 破茧初阳xuyunaoCompile Error//C++23712b2025-04-18 17:38:042025-05-19 09:22:54

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long 
int gcd(int x,int y)
{
	if(x < y) swap(x,y);
	if(y == 0) return x;
	return gcd(y,x % y);
}
int lcm(int x,int y)
{
	int ans = x / gcd(x,y) * y;
	if(ans < 0) return -1;
}
signed main()
{
	long long t;
	cin >> t;
	while(t--)
	{
		long long nn;
		cin >> nn;
		long long aa,bb,cc;
		cin >> aa >> bb >> cc;
		int a = aa;
		int b = bb;
		int c = cc;
		int n = nn;
		int ans = 0;
		ans += n / a;
		if(lcm(a,b) != -1) ans -= n / lcm(a,b);
		if(lcm(a,c) != -1) ans -= n / lcm(a,c);
		ans += n / c;
		if(lcm(lcm(a,b),c) != -1) ans += n / lcm(lcm(a,b),c); 
		long long sum = ans;
		cout << sum << endl;
	}
	return 0;
}

Details

This language is not supported yet.