QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#767979 | #4932. Moon and Sun | NYCU_template# | WA | 13ms | 8328kb | C++20 | 1.8kb | 2024-11-20 23:11:43 | 2024-11-20 23:11:44 |
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) {
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;
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();
int 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
ll tp = dif_plus * inv(C(n - 1, i)) % MOD;
ll tm = dif_minu * inv(C(n - 1, i)) % MOD;
// cerr << "i = " << i << "\n";
// cerr << arr[i] + tp << " " << arr[i] - tp << "\n";
// cerr << arr[i] + tm << " " << arr[i] - tm << "\n";
if(tp && arr[i] + tp <= 100000) {
isable = true;
}
if(tp && arr[i] - tp >= -100000) {
isable = true;
}
if(tm && arr[i] + tm <= 100000) {
isable = true;
}
if(tm && arr[i] - tm >= -100000) {
isable = true;
}
ans += isable;
}
cout << ans << "\n";
}
詳細信息
Test #1:
score: 100
Accepted
time: 13ms
memory: 7352kb
input:
5 4 1 0 7 2
output:
3
result:
ok single line: '3'
Test #2:
score: 0
Accepted
time: 13ms
memory: 6936kb
input:
4 10 20 30 -40
output:
4
result:
ok single line: '4'
Test #3:
score: 0
Accepted
time: 9ms
memory: 7908kb
input:
2 100 100
output:
0
result:
ok single line: '0'
Test #4:
score: 0
Accepted
time: 13ms
memory: 7248kb
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: 8328kb
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'