QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#133506#4932. Moon and SunVengeful_Spirit#WA 6ms6804kbC++202.5kb2023-08-02 10:22:272023-08-02 10:22:28

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-08-02 10:22:28]
  • 评测
  • 测评结果:WA
  • 用时:6ms
  • 内存:6804kb
  • [2023-08-02 10:22:27]
  • 提交

answer

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

const int MN = 1e5+5;
const int P = 235813;
int n;
int a[MN], fac[P + 5], inv[P + 5], _inv[P + 5], b[MN];

int Mul(int x, int y) {
    return (1ll * x * y % P + P) % P;
}
int Add(int x, int y) {
    return (x + y) % P;
}
int C(int n, int m) {
    return Mul(fac[n], Mul(inv[m], inv[n - m]));
}
int ton[MN * 2];
int tot = 0;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    for(int i = 1; i <= n;++i) {
        cin >> a[i];
        ++ton[a[i] + 100000];
        if(ton[a[i] + 100000] == 2) ++tot;
    }
    for(int i = fac[1] = inv[1] = fac[0] = inv[0] = 1; i < P; ++i) {
        if(i == 1) continue;
        fac[i] = Mul(fac[i - 1], i);
        inv[i] = Mul(inv[P % i], (P - P/i));
    }
    _inv[1] = _inv[0] = 1;
    for(int i = 2; i < P; ++i) _inv[i] = inv[i], inv[i] = Mul(inv[i - 1], inv[i]);
    
    int sum = 0;
    for(int i = 1; i <= n; ++i) {
        if((i & 1) != (n & 1)) b[i] = P - C(n - 1, i - 1);
        else b[i] = C(n - 1, i - 1);
        sum = Add(sum, Mul(a[i], b[i]));
    }
    // cerr << "sum = " << sum << endl;

    int ans = 0;
    for(int i = 1; i <= n; ++i) {
        int _ = Add(sum, P - Mul(a[i], b[i]));
        _ = P - _;
        // cerr << _ << endl;
        // a[i] * r = _ mod P
        // cerr << "b[i] = " << b[i] << endl;
        int r = Mul(_inv[b[i]], _);
        // cerr << "r = " << r << endl;
        // cerr << Add(Add(sum, P - Mul(a[i], b[i])), Mul(r, a[i])) << "~!~~" << endl;
        bool fl = 0;
        // cas1
        if(r >= -100000 && r <= 100000) {
            if(r != a[i]) {
                // int tmp = tot;
                // if(ton[a[i] + 100000] == 2) --tmp;
                // if(ton[r + 100000] == 1) ++tmp;
                if(ton[r + 100000] == 0) {
                    fl = 1;
                    // cerr << i << " " << r << endl;
                }
            }
        }
        // cas2
        if(!fl) {
            r -= P;
            if(r >= -100000 && r <= 100000) {
                if(r != a[i]) {
                    // int tmp = tot;
                    // if(ton[a[i] + 100000] == 2) --tmp;
                    // if(ton[r + 100000] == 1) ++tmp;
                    if(ton[r + 100000] == 0) {
                        fl = 1;
                        // cerr << i << " " << r << endl;
                    }
                }
            }
        }
        ans += fl;
    }
    cout << ans;
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 6ms
memory: 6804kb

input:

5
4 1 0 7 2

output:

3

result:

ok single line: '3'

Test #2:

score: 0
Accepted
time: 3ms
memory: 6740kb

input:

4
10 20 30 -40

output:

4

result:

ok single line: '4'

Test #3:

score: 0
Accepted
time: 1ms
memory: 6364kb

input:

2
100 100

output:

0

result:

ok single line: '0'

Test #4:

score: 0
Accepted
time: 5ms
memory: 6516kb

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: 1ms
memory: 6796kb

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:

333

result:

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