QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#421582#8111. CoachesieeWA 1ms3636kbC++17659b2024-05-25 21:50:222024-05-25 21:50:23

Judging History

你现在查看的是最新测评结果

  • [2024-05-25 21:50:23]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3636kb
  • [2024-05-25 21:50:22]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
bool check(int r, int s, int n, int m) {
	if (n > m) swap(n, m), swap(r, s);
	if (r == s) return 0;
	if (s < n) return 1;
	int k = s / n;
	return check(s - k * n, r, m - k * n, n);
}
void solve() {
	int n, a, b;
	cin >> n >> a >> b;
	int L = lcm(a, b);
	int ans = n / L * (L / a + L / b + 2);
	n %= L;
	ans += n - n / a - n / b;
	if (n < a && n < b) ans += 0;
	else {
		ans += 1;
		if (check(n % a, n % b, a, b)) ans += 1;
	}
	cout << ans << "\n";
}
signed main() {
	cin.tie(0)->sync_with_stdio(0);
	int t;
	cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3636kb

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: 3580kb

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:

6
1
4
7
6
1
3
9
17
1
6
6
1
3
6
4
6
4
15
6
12
6
10
5
1
7
1
2
7
5
7
3
6
9
5
8
13
1
11
10
7
5
9
3
5
4
11
3
4
1
12
3
7
14
5
5
12
12
10
1
13
5
1
14
10
6
4
12
1
7
10
6
1
7
2
5
10
7
11
9
16
13
1
6
9
7
2
5
3
3
10
1
9
11
2
8
8
7
7
9
3
1
2
17
1
3
3
9
4
6
8
1
12
10
13
10
1
1
7
12
6
9
9
11
1
6
2
3
9
7
6
6
9
11
...

result:

wrong answer 5th numbers differ - expected: '10', found: '6'