QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#768028 | #4932. Moon and Sun | NYCU_template# | WA | 13ms | 8100kb | C++20 | 2.3kb | 2024-11-20 23:42:14 | 2024-11-20 23:42:16 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
const int N = 200005;
const ll MOD = 235813;
ll fact[N], ifact[N];
ll fp(ll x, ll y) {
x %= MOD;
ll res = 1;
while(y) {
if(y & 1) res = res * x % MOD;
y >>= 1;
x = x * x % MOD;
}
return res;
}
ll inv(ll x) {
x %= MOD;
return fp(x, MOD - 2);
}
void build_fact() {
fact[1] = 1;
fact[0] = 1;
ifact[0] = 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();
ll n;
cin >> n;
ll ori = 0;
for(ll i = 0; i < n; i++) {
cin >> arr[i];
ll sign;
if((n - i - 1) % 2 == 0) sign = 1;
else sign = -1;
ori += sign * arr[i] * C(n - 1, i);
ori = (ori % MOD + MOD) % MOD;
}
ll ans = 0;
for(ll i = 0; i < n; i++) {
bool isable = false;
ll dif_plus = (MOD - ori);
ll dif_minu = (ori);
// C * a == dif_plus
// C * b == dif_minu
ll tp, tm;
if((n - i - 1) % 2 == 0) {
tp = dif_plus * inv(C(n - 1, i)) % MOD;
tm = dif_minu * inv(MOD - C(n - 1, i)) % MOD;
} else {
tp = dif_minu * inv(MOD - C(n - 1, i)) % MOD;
tm = dif_plus * inv(C(n - 1, i)) % MOD;
}
// cerr << "i = " << i << "\n";
// cerr << arr[i] + tp << " " << arr[i] - tm << "\n";
// cerr << arr[i] + tp << " " << arr[i] - tp << "\n";
// cerr << arr[i] + tm << " " << arr[i] - tm << "\n";
for(ll j = -10; j <= 10; j++) {
ll dif = tp + j * MOD;
ll res = arr[i] + dif;
if(dif && -100000 <= res && res <= 100000) {
isable = true;
// cerr << res << endl;
}
}
for(ll j = -10; j <= 10; j++) {
ll dif = tm + j * MOD;
ll res = arr[i] - dif;
if(dif && -100000 <= res && res <= 100000) {
isable = true;
// cerr << res << endl;
}
}
ans += isable;
}
cout << ans << "\n";
}
詳細信息
Test #1:
score: 100
Accepted
time: 13ms
memory: 6932kb
input:
5 4 1 0 7 2
output:
3
result:
ok single line: '3'
Test #2:
score: 0
Accepted
time: 13ms
memory: 6712kb
input:
4 10 20 30 -40
output:
4
result:
ok single line: '4'
Test #3:
score: 0
Accepted
time: 13ms
memory: 8100kb
input:
2 100 100
output:
0
result:
ok single line: '0'
Test #4:
score: 0
Accepted
time: 13ms
memory: 6840kb
input:
16 19 43 69 21 72 9 70 -15 25 29 -23 -13 -41 79 -89 93
output:
14
result:
ok single line: '14'
Test #5:
score: -100
Wrong Answer
time: 13ms
memory: 6748kb
input:
392 23531 -70064 22423 -55534 23391 -22700 88756 80526 36369 -10007 -28096 22617 -12591 80476 39531 -80144 -87955 93969 33358 30633 34132 -65817 -57922 -28367 -74214 50143 -36912 21570 -27256 -34989 14043 -92315 -12277 26859 97682 91797 -79591 30563 -58224 27016 -67737 99067 30626 16374 -49340 -1712...
output:
390
result:
wrong answer 1st lines differ - expected: '334', found: '390'