QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#618813#1881. Roads of the Empirecyj888TL 0ms3896kbC++11808b2024-10-07 10:35:042024-10-07 10:35:05

Judging History

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

  • [2024-10-07 10:35:05]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:3896kb
  • [2024-10-07 10:35:04]
  • 提交

answer

#include <bits/stdc++.h>
//#define int long long
#define fi first
#define se second
#define pb push_back
#define ott(i, l, r) for (int i = (l); i <= (r); i ++)
#define tto(i, l, r) for (int i = (r); i >= (l); i --)
int read () {
	int x = 0; bool f = 0; char c = getchar ();
	while (!isdigit (c)) f |= (c == '-'), c = getchar ();
	while (isdigit (c)) x = (x << 3) + (x << 1) + (c ^ 48), c = getchar ();
	if (f) x = -x; return x;
}
using namespace std;
using ll = long long;
const int N = 2e5 + 1;
int T, res; ll n, u, v;
int main () {
	T = read (); while (T --) {
		scanf ("%lld %lld %lld", &n, &u, &v);
		res = 0; while (u ^ v) {
			if (u < v) swap (u, v);
			if (!(u % n)) {
				res = -1;
				break;
			}
			u -= n % u, ++ res; 
		}
		printf ("%d\n", res);
		
	}
	return 0;
}

詳細信息

Test #1:

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

input:

4
5 1 2
8 2 5
7 7 2
6 2 5

output:

1
1
-1
2

result:

ok 4 number(s): "1 1 -1 2"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3816kb

input:

1
88 14 2

output:

2

result:

ok 1 number(s): "2"

Test #3:

score: -100
Time Limit Exceeded

input:

20
3 3 3
20 3 5
3 2 2
17 10 14
4 3 3
1 1 1
5 4 3
7 1 1
11 5 10
14 9 5
2 2 2
16 15 7
3 1 3
4 3 3
1 1 1
19 9 1
18 11 2
20 12 2
8 1 5
15 4 14

output:


result: