QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#686434 | #4932. Moon and Sun | SanguineChameleon# | WA | 4ms | 10032kb | C++20 | 1.3kb | 2024-10-29 12:55:22 | 2024-10-29 12:55:22 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
void justDoIt();
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
justDoIt();
return 0;
}
const long long MOD = 235813;
long long fact[MOD];
long long inv[MOD];
long long cont[MOD];
long long a[MOD];
void justDoIt() {
fact[0] = 1;
for (int i = 1; i < MOD; i++) {
fact[i] = fact[i - 1] * i % MOD;
}
inv[1] = 1;
for (int i = 2; i < MOD; i++) {
inv[i] = (MOD - MOD / i) * inv[MOD % i];
}
int n;
cin >> n;
for (int i = 0; i < n; i++) {
cont[i] = fact[n - 1] * inv[fact[i]] % MOD * inv[fact[n - 1 - i]] % MOD;
if ((i & 1) == 1) {
cont[i] = cont[i] * (MOD - 1) % MOD;
}
}
long long sum = 0;
for (int i = 0; i < n; i++) {
cin >> a[i];
a[i] = (MOD + a[i]) % MOD;
sum = (sum + a[i] * cont[i]) % MOD;
}
if (sum == 0) {
cout << 0;
return;
}
int res = 0;
for (int i = 0; i < n; i++) {
long long rem = (a[i] * cont[i] % MOD + MOD - sum) % MOD;
long long x = rem * inv[cont[i]] % MOD;
if ((MOD - 100000 <= x && x <= MOD - 1 )|| (0 <= x && x <= 100000)) {
res++;
}
}
cout << res << '\n';
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 4ms
memory: 9564kb
input:
5 4 1 0 7 2
output:
3
result:
ok single line: '3'
Test #2:
score: 0
Accepted
time: 4ms
memory: 10032kb
input:
4 10 20 30 -40
output:
4
result:
ok single line: '4'
Test #3:
score: 0
Accepted
time: 0ms
memory: 9304kb
input:
2 100 100
output:
0
result:
ok single line: '0'
Test #4:
score: -100
Wrong Answer
time: 4ms
memory: 9140kb
input:
16 19 43 69 21 72 9 70 -15 25 29 -23 -13 -41 79 -89 93
output:
12
result:
wrong answer 1st lines differ - expected: '14', found: '12'