Logo Wy Online Judge

WyOJ

ID提交记录ID题目HackerOwner结果提交时间测评时间
#24#184#4. 「WyOJ Round 1」启 · 破茧初阳PigsyyPigsyyFailed.2025-04-17 20:41:372025-04-17 20:41:38

详细

Extra Test:

Invalid Input

input:

1
1 0 1 1

output:


result:

FAIL Integer 0 violates the range [1, 1000000000] (stdin)

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#184#4. 「WyOJ Round 1」启 · 破茧初阳Pigsyy100912ms3492kbC++14659b2025-04-17 20:34:372025-04-17 20:40:53

answer

#include <bits/stdc++.h>
#define int long long
#define fi first
#define se second

using namespace std;

typedef long long LL;

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

void solve() {
    int n, a ,b, c;
    cin >> n >> a >> b >> c;

    int res = n / a - n / lcm(a, b) + n / c - n / lcm(a, c);
    int temp = lcm(lcm(a, b), c);
	 if (temp % a == 0 && temp % b == 0 && temp % c == 0) res += n / temp, assert(temp >= 0);
    cout << res << '\n';
}

signed main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(0);

    int dt;
    cin >> dt;

    while (dt --)
        solve();

    return 0;
}