Logo Wy Online Judge

WyOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#317#4. 「WyOJ Round 1」启 · 破茧初阳xuyunao05ms3348kbC++23712b2025-04-18 17:38:042025-04-18 18:06:27

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;
}

详细

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

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3236kb

input:

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

output:

5
2
5750
64279
42472

result:

wrong answer 3rd numbers differ - expected: '2651', found: '5750'

Test #2:

score: 0
Wrong Answer
time: 3ms
memory: 3348kb

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
2355
1148
18938

result:

wrong answer 3rd numbers differ - expected: '2326', found: '2355'

Test #3:

score: 0
Wrong Answer
time: 0ms
memory: 3240kb

input:

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

output:

4
12
184523
53787
30526

result:

wrong answer 3rd numbers differ - expected: '178281', found: '184523'

Test #4:

score: 0
Wrong Answer
time: 1ms
memory: 3240kb

input:

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

output:

3
2
140522
44116
47618

result:

wrong answer 3rd numbers differ - expected: '137255', found: '140522'

Test #5:

score: 0
Time Limit Exceeded

input:

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

output:

916617773
3119191456
2944253863
238707775
758558511
1988904955
2242369644
83414679
2053708478
530923...

result:


Test #6:

score: 0
Time Limit Exceeded

input:

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

output:

3769080080
1636851886
264014313
1850411474
1298622153
8929671
145894145
3638772278
1366556159
158219...

result:


Test #7:

score: 0
Time Limit Exceeded

input:

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

output:

10031334147
86801149
1002404789
10758368344
272870805
1301299251
4023999189
43559655
487933686
20645...

result:


Test #8:

score: 0
Time Limit Exceeded

input:

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

output:

4186274304
3823951014
12291730435
11258373318
3930377550
2876479487
2879685292
4909612919
8010498654...

result:


Test #9:

score: 0
Time Limit Exceeded

input:

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

output:

5208436879
32181644512
9585743881
6068098511
7167226136
5961403025
3843724979
5685808365
4804644420
...

result:


Test #10:

score: 0
Time Limit Exceeded

input:

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

output:

3384828351
15135841954
3977256441
7592860844
5137818959
17476000113
29047755985
4258627897
968000946...

result: