Logo Wy Online Judge

WyOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#178#4. 「WyOJ Round 1」启 · 破茧初阳Pigsyy40872ms3376kbC++141005b2025-04-17 20:24:482025-04-17 20:24:48

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 * b / __gcd(a, b);
}
inline int read()
{
    char ch = getchar();
    int x = 0, cf = 1;
    while(ch < '0' || ch > '9') {
        if(ch == '-') cf = -1;
        ch = getchar();
    }
    while(ch >= '0' && ch <= '9') {
        x = (x << 3) + (x << 1) + (ch ^ 48);
        ch = getchar();
    }
    
    return x * cf;
}
void write(int x)
{
    if(x < 0) putchar('-'), x = -x;
    if(x > 9) write(x / 10);
    putchar(x % 10 + '0');
}

void solve() {
    int n = read(), a = read(), b = read(), c = read();

    int res = n / a - n / lcm(a, b) + n / c - n / lcm(a, c);
	 res += n / lcm(lcm(a, b), c);
    write(res), putchar('\n');
}

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

    int dt = read();

    while (dt --)
        solve();

    return 0;
}

Details

小提示:点击横条可展开更详细的信息

Test #1:

score: 10
Accepted
time: 3ms
memory: 3260kb

input:

5
860162 209867 500351 439559
603171 218577 395789 743662
257237 83 83 97
771353 21 25 28
882442 63 ...

output:

5
2
2651
53995
38632

result:

ok 5 number(s): "5 2 2651 53995 38632"

Test #2:

score: 10
Accepted
time: 0ms
memory: 3264kb

input:

5
65586 755707 428352 829618
656029 940749 988704 99212
36268 81 74 19
30582 39 65 84
169669 10 30 86

output:

0
6
2326
969
13020

result:

ok 5 number(s): "0 6 2326 969 13020"

Test #3:

score: 10
Accepted
time: 3ms
memory: 3316kb

input:

5
1000000 823597 291727 302588
1000000 110582 88125 289933
1000000 56 41 6
1000000 97 68 23
1000000 ...

output:

4
12
178281
53194
27737

result:

ok 5 number(s): "4 12 178281 53194 27737"

Test #4:

score: 10
Accepted
time: 2ms
memory: 3372kb

input:

5
1000000 391577 925090 509576
1000000 602666 793626 529237
1000000 34 9 9
1000000 34 31 68
1000000 ...

output:

3
2
137255
28937
35714

result:

ok 5 number(s): "3 2 137255 28937 35714"

Test #5:

score: 0
Wrong Answer
time: 132ms
memory: 3256kb

input:

100000
296432115736998358 947322129 486697382 491023976
442633183062920521 378805523 642688939 22691...

output:

916617773
3119191458
2944253854
238707775
758558510
1988904947
2242369622
83414679
2053708470
530923...

result:

wrong answer 2nd numbers differ - expected: '3119191450', found: '3119191458'

Test #6:

score: 0
Wrong Answer
time: 148ms
memory: 3260kb

input:

100000
673374200126361826 331800367 162665250 387080263
144151428834647945 126886572 51580646 287850...

output:

3769080063
1636851827
264014313
1850411469
1298622147
8929671
145894145
3638772267
1366556156
158219...

result:

wrong answer 16th numbers differ - expected: '930291956', found: '930291959'

Test #7:

score: 0
Wrong Answer
time: 139ms
memory: 3320kb

input:

100000
534714905018631481 79508556 404238398 161736622
3826684598814001 497377457 854258623 48373266...

output:

10031334031
86801149
1002404789
10758368311
272870805
1301299248
4023999177
43559655
487933681
20645...

result:

wrong answer 3rd numbers differ - expected: '1002404788', found: '1002404789'

Test #8:

score: 0
Wrong Answer
time: 146ms
memory: 3264kb

input:

100000
1000000000000000000 366727583 374716263 685187467
1000000000000000000 877263942 598947447 372...

output:

4186274294
3823951000
12291730060
11258373300
3930379347
2876479469
2879685285
4909612902
8010498638...

result:

wrong answer 3rd numbers differ - expected: '12291730057', found: '12291730060'

Test #9:

score: 0
Wrong Answer
time: 148ms
memory: 3316kb

input:

100000
1000000000000000000 979092025 33346302 238829786
1000000000000000000 460728333 175754163 3332...

output:

5208436845
32181643966
9585743781
6068098505
7167226129
5961403001
3843724974
5685808316
4804644411
...

result:

wrong answer 3rd numbers differ - expected: '9585743799', found: '9585743781'

Test #10:

score: 0
Wrong Answer
time: 151ms
memory: 3376kb

input:

100000
1000000000000000000 437307257 195856865 910658369
1000000000000000000 384087547 596914446 797...

output:

3384828338
15135841918
3977256413
7592860727
5137818933
17475999765
29047755731
4258627888
968000942...

result:

wrong answer 3rd numbers differ - expected: '3977256414', found: '3977256413'