QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#319052#4932. Moon and Sunowen0806#TL 803ms8572kbC++202.0kb2024-02-01 17:27:132024-02-01 17:27:14

Judging History

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

  • [2024-02-01 17:27:14]
  • 评测
  • 测评结果:TL
  • 用时:803ms
  • 内存:8572kb
  • [2024-02-01 17:27:13]
  • 提交

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 + 1000*MOD) % MOD = mul*x % MOD;
        bool flag = 0;
        for(int j=-(2e8/n); j<(2e8/n); j++){
            if((sun + j*MOD) % mul == 0){
                int x = (sun + j*MOD) / mul;
                if(-1e5 <= x && x <= 1e5 && x != 0){
                    flag = 1;
                    break;
                }
            }
        }
        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();
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 803ms
memory: 8432kb

input:

5
4 1 0 7 2

output:

3

result:

ok single line: '3'

Test #2:

score: 0
Accepted
time: 577ms
memory: 8572kb

input:

4
10 20 30 -40

output:

4

result:

ok single line: '4'

Test #3:

score: -100
Time Limit Exceeded

input:

2
100 100

output:


result: