QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#767950#4932. Moon and SunNYCU_template#WA 23ms7900kbC++201.5kb2024-11-20 22:59:322024-11-20 22:59:33

Judging History

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

  • [2024-11-20 22:59:33]
  • 评测
  • 测评结果:WA
  • 用时:23ms
  • 内存:7900kb
  • [2024-11-20 22:59:32]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
const int N = 200005;
ll MOD = 235813;
ll fact[N], ifact[N];
ll fp(ll x, ll y) {
    ll res = 1;
    while(y) {
        if(y & 1) res = res * x % MOD;
        y >>= 1;
        x = x * x % MOD;
    }
    return res;
}
ll inv(ll x) {
    return fp(x, MOD - 2);
}
void build_fact() {
    fact[1] = 1;
    fact[0] = 1;
    ifact[0] = 1;
    ifact[1] = 1;
    for(ll i = 2; i < N; i++) {
        fact[i] = fact[i - 1] * i % MOD;
        ifact[i] = inv(fact[i]);
    }
}
ll C(ll a, ll b) {
    return fact[a] * ifact[b] % MOD * ifact[a - b] % MOD;
}
ll arr[N];
int main() {
    cin.tie(0)->sync_with_stdio(false);

    build_fact();

    int n;
    cin >> n;

    ll ori = 0;
    for(ll i = 0; i < n; i++) {
        cin >> arr[i];

        ll sign;
        if((n - i) % 2 == 0) sign = 1;
        else sign = -1;
        ori += sign * arr[i] * C(n - 1, i); 
        ori = (ori % MOD + MOD) % MOD;
    }
    ll ans = 0;
    for(ll i = 0; i < n; i++) {
        bool isable = false;
        ll dif_plus = (MOD - ori);
        ll dif_minu = (ori);
        // C * a == dif_plus
        ll tp = dif_plus * inv(C(n - 1, i)) % MOD;
        ll tm = dif_minu * inv(C(n - 1, i)) % MOD;
        // cerr << tp << " " << tm << "\n";
        if(tp && arr[i] + tp <= 100000) {
            isable = true;
        }
        if(tm && arr[i] - tm >= -100000) {
            isable = true;
        }
        ans += isable;
    }
    cout << ans << "\n";
}

详细

Test #1:

score: 100
Accepted
time: 23ms
memory: 6784kb

input:

5
4 1 0 7 2

output:

3

result:

ok single line: '3'

Test #2:

score: 0
Accepted
time: 22ms
memory: 7900kb

input:

4
10 20 30 -40

output:

4

result:

ok single line: '4'

Test #3:

score: 0
Accepted
time: 22ms
memory: 6808kb

input:

2
100 100

output:

0

result:

ok single line: '0'

Test #4:

score: 0
Accepted
time: 22ms
memory: 6932kb

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: 23ms
memory: 7164kb

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:

330

result:

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