QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#409862#8111. CoachesDinalWA 1ms3932kbC++14587b2024-05-12 19:47:592024-05-12 19:48:00

Judging History

This is the latest submission verdict.

  • [2024-05-12 19:48:00]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 3932kb
  • [2024-05-12 19:47:59]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
long long panduan(long long c,long long a,long long b,long long d){
	for(int i=0;i<b;++i)if((c+a*i)%b>=d){
		return c+a*i;
	}
	return LLONG_MAX;
}
int main(){
	int T;
	scanf("%d",&T);
	while(T--){
		long long n;
		int a,b;
		scanf("%lld%d%d",&n,&a,&b);
		long long l=1ll*a*b/__gcd(a,b);
		long long yc=n/a+n/b-2*(n/l);
		int ra=n%a,rb=n%b;
		long long rl=n%l;
		int ys=(rl>=min(ra,rb));
		if(panduan(ra,a,b,rb)<rl)ys=2;
		if(panduan(rb,b,a,ra)<rl)ys=2;
		// assert(ys!=1);
		printf("%lld\n",n-yc+ys);
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3908kb

input:

2
5 2 3
10 7 2

output:

3
6

result:

ok 2 number(s): "3 6"

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 3932kb

input:

1728
7 6 3
10 12 1
6 2 7
8 4 10
11 10 5
1 6 8
3 3 5
9 2 6
11 1 5
1 1 8
7 3 6
6 10 9
2 1 7
3 4 7
8 3 4
4 5 9
9 4 3
6 2 8
11 4 1
6 8 4
11 1 8
9 11 2
9 6 1
5 3 8
7 1 8
7 11 12
3 9 1
2 12 6
7 2 6
5 11 10
9 5 3
3 6 2
7 5 5
12 4 3
7 8 2
8 11 11
10 1 10
5 1 7
9 1 7
8 1 6
8 4 6
5 5 11
12 3 7
3 6 8
6 3 11
6 ...

output:

7
1
4
7
11
2
3
7
3
1
7
7
1
4
6
5
6
4
3
6
2
6
2
5
1
8
1
3
6
6
7
3
8
8
5
9
2
1
2
2
7
5
9
4
5
4
11
3
2
2
12
4
7
2
6
5
12
2
11
1
9
6
2
3
10
6
4
12
2
13
10
7
2
7
2
6
10
8
11
9
3
3
2
6
9
9
3
6
3
4
10
2
9
11
2
8
8
7
7
9
4
1
3
3
1
3
4
9
4
6
8
1
12
6
3
10
1
2
10
12
7
2
9
11
2
6
3
3
13
7
6
6
9
11
9
2
3
5
3
5
...

result:

wrong answer 1st numbers differ - expected: '6', found: '7'