QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#319057#4932. Moon and Sunowen0806WA 3ms12016kbC++201.9kb2024-02-01 18:04:142024-02-01 18:04:15

Judging History

你现在查看的是最新测评结果

  • [2024-02-01 18:04:15]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:12016kb
  • [2024-02-01 18:04:14]
  • 提交

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;
    }
    // cout << sun << endl;

    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;

        int k = tmp * getInv(mul) % MOD;
        int kk = k - MOD;
        // cout << k << " " << kk << endl;
        if(-1e5 <= k && k <= 1e5 && abs(k) != abs(a[i])) ans++;
        if(-1e5 <= kk && kk <= 1e5 && abs(kk) != abs(a[i])) ans++;
        // cout << mul * k << " ";
        // if(MOD <= mul * k && mul * k <= MOD) 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();
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 8440kb

input:

5
4 1 0 7 2

output:

3

result:

ok single line: '3'

Test #2:

score: -100
Wrong Answer
time: 3ms
memory: 12016kb

input:

4
10 20 30 -40

output:

3

result:

wrong answer 1st lines differ - expected: '4', found: '3'