QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#399456 | #6748. Spin the Wheel | szj | WA | 5ms | 4096kb | C++11 | 1.2kb | 2024-04-26 13:31:26 | 2024-04-26 13:31:28 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define IOS std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
const long double PI = acos(-1);
const ll mod = 998244353;
const int maxn = 1e6 + 7;
const int P = 13331;
ll qgcd(ll a, ll b) {
return b == 0 ? a : qgcd(b, a % b);
}
ll qpow(ll a, ll b) {
ll ans = 1;
while (b) {
if (b & 1)
ans = ans * a % mod;
a = a * a % mod;
b >>= 1;
}
return ans % mod;
}
int n;
int a[maxn];
void solve() {
cin >> n;
int flag = 1;
int idx = 0;
for (int i = 1; i <= n; i++) {
cin >> a[i];
if (a[i] != 0)
flag = 0;
if (a[i] == 0)
idx = i;
}
if (flag) {
cout << 0;
return;
} else if (idx == 0) {
cout << -1;
return;
}
int z = idx + 1;
if (z > n)
z = 1;
ll cnt = a[z];
ll y = 0;
for (int i = idx; i <= n; i++) {
if (a[i] != (cnt * y % n)) {
cout << -1;
return;
}
y++;
}
if (idx != 1)
cnt++;
cout << cnt;
}
int main() {
IOS;
int T = 1;
// cin >> T;
while (T--) {
solve();
}
return 0;
}
/*
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3708kb
input:
5 1 3 0 2 4
output:
3
result:
ok 1 number(s): "3"
Test #2:
score: -100
Wrong Answer
time: 5ms
memory: 4096kb
input:
100000 0 55555 11110 66665 22220 77775 33330 88885 44440 99995 55550 11105 66660 22215 77770 33325 88880 44435 99990 55545 11100 66655 22210 77765 33320 88875 44430 99985 55540 11095 66650 22205 77760 33315 88870 44425 99980 55535 11090 66645 22200 77755 33310 88865 44420 99975 55530 11085 66640 221...
output:
55556
result:
wrong answer 1st numbers differ - expected: '55555', found: '55556'