QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#208473 | #4932. Moon and Sun | ZiadElGafy# | WA | 15ms | 5300kb | C++20 | 2.3kb | 2023-10-09 17:22:34 | 2023-10-09 17:22:34 |
Judging History
answer
#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define el '\n'
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef __int128 bigInt;
using namespace std;
const int N = 1e5 + 5, INF = 1e9 + 5, mod = 235813, LOG = 21, SQ = 500;
int add(int a, int b) {
while (a < 0) {
a += mod;
}
a %= mod;
while (b < 0) {
b += mod;
}
b %= mod;
return (a + b) % mod;
}
int mul(int a, int b) {
while (a < 0) {
a += mod;
}
a %= mod;
while (b < 0) {
b += mod;
}
b %= mod;
return 1LL * a * b % mod;
}
int fp(int b, int p) {
int ret = 1;
while(p) {
if(p & 1)
ret = (1LL * ret * b) % mod;
p >>= 1;
b = (1LL * b * b) % mod;
}
return ret;
}
int inv(int x) {
return fp(x, mod - 2);
}
int fac[N], invFac[N];
void pre() {
fac[0] = invFac[0] = 1;
for (int i = 1; i < N; i++)
fac[i] = (1LL * fac[i - 1] * i) % mod;
invFac[N - 1] = inv(fac[N - 1]);
for (int i = N - 2; i >= 1; i--)
invFac[i] = (1LL * invFac[i + 1] * (i + 1)) % mod;
}
int C(int n, int r) {
assert(n >= r);
return 1LL * fac[n] * (1LL * invFac[r] *invFac[n - r] % mod) % mod;
}
int n, a[N], co[N];
void doWork() {
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
int sign = (n % 2 ? 1 : -1);
for (int i = 1; i <= n; i++) {
co[i] = mul(sign, C(n - 1, i - 1));
sign *= -1;
}
ll sum = 0;
for (int i = 1; i <= n; i++) {
sum = add(sum, mul(co[i], a[i]));
}
sum %= mod;
int ans = 0;
for (int i = 1; i <= n; i++) {
int rem = mul(co[i], a[i]);
int curSum = add(sum, -rem);
int x = mul(-curSum, inv(co[i]));
if (x == a[i]) {
continue;
}
if (x <= 100000) {
ans++;
}
else if (x >= mod - 100000 and x < mod) {
ans++;
}
}
cout << ans << el;
}
int main() {
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
pre();
int tests = 1;
// cin >> tests;
for (int i = 1; i <= tests; i++) {
doWork();
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 4460kb
input:
5 4 1 0 7 2
output:
3
result:
ok single line: '3'
Test #2:
score: 0
Accepted
time: 1ms
memory: 4464kb
input:
4 10 20 30 -40
output:
4
result:
ok single line: '4'
Test #3:
score: 0
Accepted
time: 1ms
memory: 4468kb
input:
2 100 100
output:
0
result:
ok single line: '0'
Test #4:
score: 0
Accepted
time: 1ms
memory: 4456kb
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: 0
Accepted
time: 1ms
memory: 4524kb
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:
334
result:
ok single line: '334'
Test #6:
score: 0
Accepted
time: 1ms
memory: 4460kb
input:
292 -99191 -98152 -98063 -98047 -97715 -97353 -97211 -96714 -94868 -94586 -93910 -92928 -91078 -90877 -89315 -88925 -88630 -87392 -87209 -86028 -84609 -84095 -83780 -83406 -83315 -82724 -82079 -81548 -81481 -81308 -80690 -80431 -79941 -76493 -75868 -75033 -74227 -74117 -73703 -73586 -73502 -73306 -7...
output:
248
result:
ok single line: '248'
Test #7:
score: 0
Accepted
time: 1ms
memory: 4412kb
input:
309 98887 98493 98409 98076 97889 97105 96335 95922 95157 94858 94022 93801 93788 93600 93566 93431 92058 91804 90751 90382 90197 89866 89067 88948 88524 88049 87464 87356 85865 85383 85000 84838 84429 83352 81775 81241 80996 80303 79421 79359 79084 78979 78579 78311 77853 77615 77199 76350 75853 73...
output:
263
result:
ok single line: '263'
Test #8:
score: 0
Accepted
time: 1ms
memory: 4404kb
input:
107 -44185 93780 -58049 38184 -80116 15432 -76859 39059 -42043 34396 7818 89779 -22224 44835 -99460 29444 -54582 20083 -9025 94424 17752 92561 66770 82965 -96626 39301 -11864 62742 33462 37023 1965 29724 -94180 58174 -33205 83913 -80551 8495 -11590 98236 -23377 38796 3994 61340 -81823 -7796 -54447 6...
output:
88
result:
ok single line: '88'
Test #9:
score: 0
Accepted
time: 8ms
memory: 4752kb
input:
43417 -88011 3526 -87784 -5063 81553 -63127 47982 -13045 79619 -62489 34521 43047 5792 4605 -39109 -35885 99600 -99381 -27560 19465 -5867 29820 -24349 -98963 95913 94051 -65067 32778 -34400 -41369 36075 -59926 -87358 85147 21454 -38148 -4467 -19354 -43198 26617 -52316 78137 2906 -13476 -26412 85650 ...
output:
36822
result:
ok single line: '36822'
Test #10:
score: 0
Accepted
time: 15ms
memory: 5172kb
input:
90838 -89537 65011 22520 -7843 8633 -56201 -11753 -61717 -21438 27748 -2513 -537 75559 11717 19211 72302 52392 90298 44251 81002 -43966 -52133 -96725 -16064 -2814 13471 10229 -2230 13631 -48825 23208 -50077 70706 -44059 -54640 13408 9308 11392 1294 45011 98620 -52030 -96925 86174 -27533 -57566 -7870...
output:
76911
result:
ok single line: '76911'
Test #11:
score: 0
Accepted
time: 8ms
memory: 4892kb
input:
44994 -72728 -84149 715 -72757 -63184 65252 248 -26899 -61524 -32934 69222 -87290 11716 -44300 -32029 -89748 -91620 34038 488 -1404 -39640 78030 149 73272 56552 74365 -17748 -86455 79671 -89249 -32298 -71778 -46249 29495 -88982 -44163 -22883 -52013 -17137 -91156 29037 73521 -97656 -43895 -50704 3465...
output:
38250
result:
ok single line: '38250'
Test #12:
score: 0
Accepted
time: 4ms
memory: 4600kb
input:
16942 69607 -32741 -90994 -85656 7263 71160 -77525 -27855 -89319 -23418 15103 -48641 -3483 -7983 66210 -47519 -23372 72744 86506 -90670 88640 6659 19177 46053 90112 -97538 -47290 19944 9270 -17233 -60434 32328 -95953 -7320 14762 91692 62164 30763 -11861 30320 72857 87290 -48830 66581 -49365 39438 -5...
output:
14384
result:
ok single line: '14384'
Test #13:
score: 0
Accepted
time: 9ms
memory: 5200kb
input:
93792 -51282 -78078 -98161 -33038 70567 74121 47320 69018 -84409 87532 84776 -84807 94122 12286 -15869 91012 33365 9301 -29464 98094 -69170 31301 12816 83996 -41815 -24100 -9963 -66423 97029 -28805 -76234 53572 4649 72153 -88090 17261 88412 -18087 -12552 -96910 96516 -27382 79692 46837 -20148 60526 ...
output:
79530
result:
ok single line: '79530'
Test #14:
score: -100
Wrong Answer
time: 15ms
memory: 5300kb
input:
100000 77271 -81218 98233 -32336 -96866 -29427 47854 -480 -82709 11310 -45867 -6084 61754 63418 84189 25888 4218 -74264 8692 -61738 95171 58183 36976 60432 -67103 16980 30074 -58774 -1926 -70432 35912 18623 71986 -40125 28523 -1117 -75694 -7357 -54495 -21325 -46743 -58620 2829 21697 49942 94778 8105...
output:
50138
result:
wrong answer 1st lines differ - expected: '0', found: '50138'