QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#240248#4932. Moon and SunNYCU_gAwr_gurA#WA 2ms5172kbC++201.6kb2023-11-05 13:58:352023-11-05 13:58:35

Judging History

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

  • [2023-11-05 13:58:35]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:5172kb
  • [2023-11-05 13:58:35]
  • 提交

answer

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

#ifdef DEBUG
#define fast
#else
#define fast cin.tie(0)->sync_with_stdio(0)
#define cerr if(1);else cerr
#define endl '\n'
#endif
#define _ <<' '<<
#define ALL(v) v.begin(),v.end()
#define ft first
#define sd second

using ll = long long;
using ld = long double;
using pii = pair<int,int>;

constexpr ll MOD = 235'813;
constexpr int MAXN = 1e5;

ll fpow(ll a, ll b) {
    ll r = 1;
    while (b) {
        if (b & 1) r = r * a % MOD;
        a = a * a % MOD;
        b >>= 1;
    }
    return r;
}

ll inverse(ll x) {
    return fpow(x, MOD-2);
}

ll fac[MAXN+1], infac[MAXN+1];
ll C(int n, int m) {
    return fac[n] * infac[m] % MOD * infac[n-m] % MOD;
}

signed main() {
    fast;

    fac[0] = 1;
    for (int i = 1; i <= MAXN; i++)
        fac[i] = fac[i-1] * i % MOD;
    infac[MAXN] = inverse(fac[MAXN]);
    for (int i = MAXN; i > 0; i--)
        infac[i-1] = infac[i] * i % MOD;

    int n;
    cin >> n;
    vector<int> A(n);
    for (auto &x: A) cin >> x;

    ll sum = 0;
    for (int i = n-1, j = 1; i >= 0; i--, j *= -1) {
        ll t = C(n-1, i) * j + (j < 0 ? MOD : 0);
        cerr _ i _ A[i] _ t _ endl;
        sum = (sum + t * A[i]) % MOD;
    }
    cerr _ sum _ endl;

    int c = 0;
    for (int i = n-1, j = 1; i >= 0; i--, j *= -1) {
        ll t = C(n-1, i) * j + (j < 0 ? MOD : 0);
        ll x = sum * inverse(t) % MOD;
        ll y = (A[i] + x) % MOD;
        if (y < 0) y += MOD;
        if (y > MAXN) y -= MOD;
        cerr _ i _ A[i] _ '/' _ x _ y _ endl;
        if (-MAXN <= y and y < MAXN and x != 0)
            c++;
    }
    cout << c << endl;

    return 0;
}

詳細信息

Test #1:

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

input:

5
4 1 0 7 2

output:

3

result:

ok single line: '3'

Test #2:

score: 0
Accepted
time: 2ms
memory: 5080kb

input:

4
10 20 30 -40

output:

4

result:

ok single line: '4'

Test #3:

score: 0
Accepted
time: 2ms
memory: 5088kb

input:

2
100 100

output:

0

result:

ok single line: '0'

Test #4:

score: 0
Accepted
time: 2ms
memory: 5108kb

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: 0ms
memory: 5172kb

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:

325

result:

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