QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#319053#4932. Moon and Sunowen0806#WA 572ms11988kbC++202.0kb2024-02-01 17:28:562024-02-01 17:28:56

Judging History

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

  • [2024-02-01 17:28:56]
  • 评测
  • 测评结果:WA
  • 用时:572ms
  • 内存:11988kb
  • [2024-02-01 17:28:56]
  • 提交

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) = mul*x;
        bool flag = 0;
        for(int j=-(1e8/n); j<(1e8/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();
    }
}

詳細信息

Test #1:

score: 100
Accepted
time: 400ms
memory: 11988kb

input:

5
4 1 0 7 2

output:

3

result:

ok single line: '3'

Test #2:

score: 0
Accepted
time: 289ms
memory: 8608kb

input:

4
10 20 30 -40

output:

4

result:

ok single line: '4'

Test #3:

score: 0
Accepted
time: 572ms
memory: 8328kb

input:

2
100 100

output:

0

result:

ok single line: '0'

Test #4:

score: 0
Accepted
time: 327ms
memory: 11976kb

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: 324ms
memory: 8524kb

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:

346

result:

wrong answer 1st lines differ - expected: '334', found: '346'