QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#319048 | #4932. Moon and Sun | owen0806# | WA | 2ms | 12056kb | C++20 | 1.9kb | 2024-02-01 17:08:22 | 2024-02-01 17:08:23 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
#define PB push_back
#define pii pair<int, int>
#define ll long long
using namespace std;
const int N = 2e5 + 5;
const int INF = 1e18;
const int MOD = 235813;
int a[N], arr[N];
ll fac[1000020], inv[1000020];
int qpow(int x, int y){
int ret = 1;
while(y){
if(y & 1) ret = ret * x % MOD;
x = x * x % MOD;
y >>= 1;
}
return ret;
}
ll getInv(ll a){ return qpow(a,MOD-2); } //逆元
void init(int n){ // O(N)
fac[0] = 1;
for(ll i = 1; i <= n; i++)
fac[i] = fac[i-1] * i % MOD;
inv[n] = getInv(fac[n]);
for(ll i = n-1; i >= 0; i--)
inv[i] = inv[i+1] * (i+1) % MOD;
}
ll C(int n,int m){ //O(1)
if(m > n) return 0;
return fac[n] * inv[m] % MOD * inv[n-m] % MOD;
}
void solve(){
init(1e5+5);
int n;
cin >> n;
for(int i=1; i<=n; i++) cin >> a[i];
int sun = 0;
for(int i=1; i<=n; i++){
if(i%2) sun = (sun + a[i]*C(n-1, i-1)%MOD) % MOD;
else sun = (sun - a[i]*C(n-1, i-1)%MOD + MOD) % MOD;
}
int ans = 0;
for(int i=1; i<=n; i++){
int tmp, mul = C(n-1, i-1);
if(i%2) tmp = (sun - a[i]*C(n-1, i-1)%MOD + MOD) % MOD;
else tmp = (sun + a[i]*C(n-1, i-1)%MOD) % MOD;
//(sun +- (a[i]+-a'[i])*mul) % MOD = 0;
//(-26 + (-78600) * 6 ) % MOD = 0;
//(sun +- x*mul) % MOD = 0;
//(-26 + A*MOD)%MOD = mul*x % MOD;
bool flag = 0;
for(int j=-300; j<300; j++){
if((sun + j*MOD) % mul == 0){
int x = (sun + j*MOD) / mul;
if(-1e5 <= x && x <= 1e5 && x != 0) flag = 1;
}
}
if(flag) ans++;
}
cout << ans << endl;
}
signed main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int T = 1;
// cin >> T;
while(T--){
solve();
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 2ms
memory: 8396kb
input:
5 4 1 0 7 2
output:
3
result:
ok single line: '3'
Test #2:
score: 0
Accepted
time: 2ms
memory: 12056kb
input:
4 10 20 30 -40
output:
4
result:
ok single line: '4'
Test #3:
score: 0
Accepted
time: 2ms
memory: 11936kb
input:
2 100 100
output:
0
result:
ok single line: '0'
Test #4:
score: -100
Wrong Answer
time: 2ms
memory: 8200kb
input:
16 19 43 69 21 72 9 70 -15 25 29 -23 -13 -41 79 -89 93
output:
10
result:
wrong answer 1st lines differ - expected: '14', found: '10'