QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#618812#1881. Roads of the Empirecyj888WA 0ms3796kbC++11812b2024-10-07 10:33:412024-10-07 10:33:41

Judging History

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

  • [2024-10-07 10:33:41]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3796kb
  • [2024-10-07 10:33:41]
  • 提交

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 *= n, ++ res; 
		}
		printf ("%d\n", res);
		
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

2
2
-1
2

result:

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