QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#767938 | #4932. Moon and Sun | NYCU_template# | WA | 23ms | 7528kb | C++20 | 1.5kb | 2024-11-20 22:52:30 | 2024-11-20 22:52:31 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
const int N = 200005;
ll MOD = 235813;
ll fact[N], ifact[N];
ll fp(ll x, ll y) {
ll res = 1;
while(y) {
if(y & 1) res = res * x % MOD;
y >>= 1;
x = x * x % MOD;
}
return res;
}
ll inv(ll x) {
return fp(x, MOD - 2);
}
void build_fact() {
fact[1] = 1;
ifact[1] = 1;
for(ll i = 2; i < N; i++) {
fact[i] = fact[i - 1] * i % MOD;
ifact[i] = inv(fact[i]);
}
}
ll C(ll a, ll b) {
return fact[a] * ifact[b] % MOD * ifact[a - b] % MOD;
}
ll arr[N];
int main() {
cin.tie(0)->sync_with_stdio(false);
build_fact();
int n;
cin >> n;
ll ori = 0;
for(ll i = 1; i <= n; i++) {
cin >> arr[i];
ll sign;
if((n - i) % 2 == 0) sign = 1;
else sign = -1;
ori += sign * arr[i] * C(n, i);
ori = (ori % MOD + MOD) % MOD;
}
ll ans = 0;
for(ll i = 1; i <= n; i++) {
bool isable = false;
ll dif_plus = (MOD - ori);
ll dif_minu = (ori);
// C * a == dif_plus
ll tp = dif_plus * inv(C(n, i)) % MOD;
ll tm = dif_minu * inv(C(n, i)) % MOD;
// cerr << tp << " " << tm << "\n";
if(arr[i] + tp <= 100000) {
isable = true;
}
if(arr[i] - tm >= -100000) {
isable = true;
}
ans += isable;
}
cout << ans << "\n";
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 20ms
memory: 7528kb
input:
5 4 1 0 7 2
output:
3
result:
ok single line: '3'
Test #2:
score: 0
Accepted
time: 23ms
memory: 6852kb
input:
4 10 20 30 -40
output:
4
result:
ok single line: '4'
Test #3:
score: -100
Wrong Answer
time: 23ms
memory: 6732kb
input:
2 100 100
output:
2
result:
wrong answer 1st lines differ - expected: '0', found: '2'