QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#686431#4932. Moon and SunSanguineChameleon#WA 4ms10916kbC++201.3kb2024-10-29 12:54:082024-10-29 12:54:12

Judging History

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

  • [2024-10-29 12:54:12]
  • 评测
  • 测评结果:WA
  • 用时:4ms
  • 内存:10916kb
  • [2024-10-29 12:54:08]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

void justDoIt();

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    justDoIt();
    return 0;
}

const long long MOD = 235813;
long long fact[MOD];
long long inv[MOD];
long long cont[MOD];
long long a[MOD];

void justDoIt() {
    fact[0] = 1;
    for (int i = 1; i < MOD; i++) {
        fact[i] = fact[i - 1] * i % MOD;
    }
    inv[1] = 1;
    for (int i = 2; i < MOD; i++) {
        inv[i] = (MOD - MOD / i) * inv[MOD % i];
    }
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cont[i] = fact[n - 1] * inv[fact[i]] % MOD * inv[fact[n - 1 - i]] % MOD;
        if ((i & 1) == 1) {
            cont[i] = cont[i] * (MOD - 1) % MOD;
        }
    }
    long long sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        sum = (sum + a[i] * cont[i]) % MOD;
    }
    if (sum == 0) {
        cout << 0;
        return;
    }
    int res = 0;
    for (int i = 0; i < n; i++) {
        long long rem = (a[i] * cont[i] % MOD + MOD - sum) % MOD;
        long long x = rem * inv[cont[i]] % MOD;
        if ((MOD - 100000 <= x && x <= MOD - 1 )|| (0 <= x && x <= 100000)) {
            res++;
        }
    }
    cout << res << '\n';
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 4ms
memory: 9160kb

input:

5
4 1 0 7 2

output:

3

result:

ok single line: '3'

Test #2:

score: 0
Accepted
time: 0ms
memory: 10364kb

input:

4
10 20 30 -40

output:

4

result:

ok single line: '4'

Test #3:

score: 0
Accepted
time: 0ms
memory: 10916kb

input:

2
100 100

output:

0

result:

ok single line: '0'

Test #4:

score: -100
Wrong Answer
time: 0ms
memory: 9516kb

input:

16
19 43 69 21 72 9 70 -15 25 29 -23 -13 -41 79 -89 93

output:

12

result:

wrong answer 1st lines differ - expected: '14', found: '12'