QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#203903#4932. Moon and Suntriplem5ds#WA 2ms5200kbC++232.3kb2023-10-06 21:54:542023-10-06 21:54:54

Judging History

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

  • [2023-10-06 21:54:54]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:5200kb
  • [2023-10-06 21:54:54]
  • 提交

answer

/// Msaa el 5ra
#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx,avx2,fma")

#include "bits/stdc++.h"

using namespace std;

#define pb push_back
#define F first
#define S second
#define f(i, a, b)  for(int i = a; i < b; i++)
#define all(a)  a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(x) (int)(x).size()
#define mp(x, y) make_pair(x,y)
#define popCnt(x) (__builtin_popcountll(x))
#define int ll

using ll = long long;
using ii = pair<int, int>;
using ull = unsigned long long;

const int N = 1e5 + 5, LG = 18, MOD = 235813;
const long double PI = acos(-1);
const long double EPS = 1e-7;

vector<int> solve(vector<vector<int>> vec) {
    if (vec.size() == 1)return vec[0];
    vector<vector<int>> ret;
    for (int i = 1; i < vec.size(); i++) {
        ret.push_back(vec[i]);
        for (int j = 0; j < vec[i].size(); j++) {
            ret.back()[j] -= vec[i - 1][j];
        }
    }
    return solve(ret);
}

ll F[N], iF[N];

ll fast(ll b, ll e) {
    ll res = 1;
    for (; e; e >>= 1, b = b * b % MOD)
        if (e & 1)
            res = res * b % MOD;
    return res;
}

void init() {
    F[0] = 1;
    f(i, 1, N)F[i] = F[i - 1] * i % MOD;
    iF[N - 1] = fast(F[N - 1], MOD - 2);
    for (int i = N - 2; i >= 0; --i)
        iF[i] = iF[i + 1] * (i + 1) % MOD;
}

int C(int n, int k) {
    if (k > n || k < 0)
        return 0;
    return 1ll * iF[k] * F[n] % MOD * iF[n - k] % MOD;
}

void doWork() {
    int n;
    cin >> n;
    vector<int> vec(n);
    int lstElement = 0;
    f(i, 0, n) {
        cin >> vec[i];
        lstElement = (lstElement + MOD + (((n & 1) ^ (i & 1)) ? 1 : -1) * C(n - 1, i) * vec[i] % MOD) % MOD;
    }
    int ans = 0;
    f(i, 0, n) {
        int contribution = (((n & 1) ^ (i & 1)) ? 1 : -1) * C(n - 1, i);
        int cur = (lstElement + MOD - vec[i] * contribution % MOD) % MOD;
        cur = cur * fast(abs(contribution), MOD - 2) % MOD;
        if (cur <= 100000 || cur >= MOD - 100000) {
            ans += 1;
        }
    }
    cout << ans << '\n';
}

int32_t main() {
#ifdef ONLINE_JUDGE
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif // ONLINE_JUDGE
    init();
    int t = 1;
//    cin >> t;
    while (t--) {
        doWork();
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

5
4 1 0 7 2

output:

3

result:

ok single line: '3'

Test #2:

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

input:

4
10 20 30 -40

output:

4

result:

ok single line: '4'

Test #3:

score: -100
Wrong Answer
time: 2ms
memory: 5200kb

input:

2
100 100

output:

2

result:

wrong answer 1st lines differ - expected: '0', found: '2'