QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#618812 | #1881. Roads of the Empire | cyj888 | WA | 0ms | 3796kb | C++11 | 812b | 2024-10-07 10:33:41 | 2024-10-07 10:33:41 |
Judging History
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'