QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#195197 | #4932. Moon and Sun | bruh | AC ✓ | 52ms | 4532kb | C++20 | 4.3kb | 2023-10-01 02:07:47 | 2023-10-01 02:07:48 |
Judging History
answer
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
typedef __int128 Int;
typedef vector<ll> vi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef pair<ll, ii> iii;
typedef unordered_map<ll, ll> unmap;
template<typename T> using pqmax = priority_queue<T>;
template<typename T> using pqmin = priority_queue<T, vector<T>,greater<T>>;
template<typename T> using oset = tree<T, null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
#define fi first
#define se second
#define sz size()
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define lg(n) (ll)__lg(n)
#define btpc __builtin_popcount
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define FOR(i,a,b) for(ll i = a; i <= b; i ++)
#define REP(i,a,b) for(ll i = a; i < b; i ++)
#define FORD(i,a,b) for(ll i = a; i >= b; i --)
#define FORS(i,a,b,c) for(ll i = a; i <= b; i += c)
#define FORDS(i,a,b,c) for(ll i = a; i >= b; i -= c)
#define FORA(x,a) for(auto x: a)
#define FORAA(l,r,a) for(auto [l, r]: a)
#define EL cerr << endl;
#define DEBUGN(a) cerr << a << endl;
#define DEBUGA(a, n) FOR (i, 1, n) cerr << a[i] << " "; cerr << endl;
#define DEBUG_AOP(a, n) FOR (i, 1, n) cerr << a[i].fi << " " << a[i].se << endl;
#define DEBUG_A2D(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cerr << a[i][j] << " "; cerr << endl;}
#define DEBUG cerr << "shut the fuck up please :3" << endl;
#define YES cout << "YES\n"; return;
#define NO cout << "NO\n"; return;
template<class X, class Y> bool mimi(X &x, const Y &y) {if(x>y){x=y;return 1;}return 0;}
template<class X, class Y> bool mama(X &x, const Y &y) {if(x<y){x=y;return 1;}return 0;}
istream &operator >> (istream &st, Int &a) {string s;a=0;st>>s;bool g=1;REP(i,0,s.sz){if(i==0&&s[i]=='-'){g = 0;continue;}a=a*10+s[i]-'0';}if(!g)a=-a;return st;}
ostream &operator << (ostream &st, const Int &a) {Int t=a;if(t==0){st<<0;return st;}if(t<0){st<<'-';t=-t;}string b;while(t!=0){b.pb((t%10+'0'));t/=10;}reverse(all(b));st<<b;return st;}
const ll nom = 2;
const ll base[] = {577, 677, 877, 977};
// const ll mod[] = {(ll)1e9 + 2277, (ll)1e9 + 5277, (ll)1e9 + 8277, (ll)1e9 + 9277};
const ii dir[] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}, {1, 1}, {1, -1}, {-1, 1}, {-1, -1}};
const ll INF = 1e18;
const ll N = 1e6 + 5;
const ll T = 4*N - 3;
const ll M = 1e9 + 7;
const int maxn = 100005;
const int mod = 235813;
const int lrange = -100000;
const int rrange = 100000;
int power(int a, int b, int mod) {
if (b == 0) return 1;
int ret = power(a, b>>1, mod);
ret = (ll)ret * ret % mod;
if (b & 1) ret = (ll)ret * a % mod;
return ret;
}
int inverse(int a, int m) {
return power(a, m-2, m);
}
int posmod(int x) { return (x % mod + mod) % mod; }
int negmod(int x) { return (x % mod - mod) % mod; }
int n;
int A[maxn];
int val[maxn];
void solve(ll testID) {
scanf("%d", &n);
for (int i = 0; i < n; ++i)
scanf("%d", &A[i]);
ll p = 1;
int a = n-1, b = 1;
int sign = 1;
for (int i = n-1; i >= 0; --i) {
val[i] = sign * p * A[i] % mod;
p = p * a % mod;
p = p * inverse(b, mod) % mod;
sign = -sign, --a, ++b;
}
int total = 0;
for (int i = 0; i < n; ++i)
total = (total + val[i]) % mod;
if (total == 0) {
printf("%d\n", 0);
return;
}
int ans = 0;
sign = 1, p = 1, a = n-1, b = 1;
for (int i = n-1; i >= 0; --i) {
int target = -(total - val[i]) % mod;
int out = (ll)target * inverse(p, mod) % mod;
out *= sign;
bool found = false;
int neg = negmod(out);
if (lrange <= neg && neg <= rrange && neg != A[i]) {
found = true;
}
int pos = posmod(out);
if (lrange <= pos && pos <= rrange && pos != A[i]) {
found = true;
}
if (found) {
++ans;
}
p = p * a % mod;
p = p * inverse(b, mod) % mod;
sign = -sign, --a, ++b;
}
printf("%d\n", ans);
}
signed main() {
ios_base::sync_with_stdio(0); cin.tie(0);
int test = 1;
// cin >> test;
FOR (i, 1, test) solve(i);
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3740kb
input:
5 4 1 0 7 2
output:
3
result:
ok single line: '3'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3664kb
input:
4 10 20 30 -40
output:
4
result:
ok single line: '4'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3788kb
input:
2 100 100
output:
0
result:
ok single line: '0'
Test #4:
score: 0
Accepted
time: 1ms
memory: 3676kb
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: 0ms
memory: 3796kb
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: 3676kb
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: 3744kb
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: 3744kb
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: 19ms
memory: 4032kb
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: 47ms
memory: 4472kb
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: 25ms
memory: 4056kb
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: 10ms
memory: 3792kb
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: 49ms
memory: 4424kb
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: 0
Accepted
time: 22ms
memory: 4532kb
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:
0
result:
ok single line: '0'
Test #15:
score: 0
Accepted
time: 1ms
memory: 3668kb
input:
12 -23 -4 59 63 6 -4 14 -22 86 68 -86 -33
output:
12
result:
ok single line: '12'
Test #16:
score: 0
Accepted
time: 48ms
memory: 4456kb
input:
100000 -13883 72674 20854 37233 54951 11108 -11765 -36606 -84407 85732 35380 -13983 -5249 47205 69222 99602 -95499 6116 97819 50040 88298 -15701 94436 -86192 1878 -35459 -82694 84367 -6535 -70592 -85504 39059 28235 80438 33077 16756 -72938 90074 -66148 64330 -87020 80846 20930 -77614 -67525 5437 753...
output:
84552
result:
ok single line: '84552'
Test #17:
score: 0
Accepted
time: 21ms
memory: 4468kb
input:
99999 90711 -46558 49057 41548 66787 -15506 35943 37727 -85891 24512 82164 68484 69390 26841 -80470 85476 -75405 97212 -1304 -45420 -47639 -43465 -49873 -26245 22523 -12946 58195 7312 37853 -63371 88827 18138 85526 -18099 -24563 37598 -31407 4966 -29108 2521 -17167 -57328 -20431 56452 80178 -52726 -...
output:
0
result:
ok single line: '0'
Test #18:
score: 0
Accepted
time: 52ms
memory: 4440kb
input:
99999 38695 39525 -68995 -88038 7807 -78730 67070 -6421 -64219 -39174 -1886 2861 17965 -66324 -30628 -77185 38842 9121 49541 96264 67475 84105 97703 -38003 94001 -82166 11537 73291 56987 93472 -67467 39953 -16541 56900 -33659 -5895 -92409 -86038 -31172 46739 40723 92572 -70259 11790 -38508 -6660 -38...
output:
84855
result:
ok single line: '84855'
Test #19:
score: 0
Accepted
time: 44ms
memory: 4444kb
input:
100000 -57541 64133 70032 -4775 -94372 42019 -52807 -85707 21212 37652 45542 -86138 87483 33849 20297 98114 -90474 68314 10751 90954 -72123 24865 -80452 92837 96472 80404 -29980 -18070 -19119 -78145 66496 -96497 -69281 -5609 -91547 19610 21896 -38978 -54983 -98959 -40094 2855 63474 47679 -53566 -200...
output:
84795
result:
ok single line: '84795'
Test #20:
score: 0
Accepted
time: 48ms
memory: 4440kb
input:
99999 38699 37868 44663 -57298 11473 32691 -72334 41302 -85459 -88491 -48509 16489 48674 30599 -41022 -70906 68760 -89016 6447 59595 -79621 -21363 -11911 30297 39051 -62342 -31154 17876 77439 -40181 -24312 87961 -2919 -54859 -11244 54848 91288 28836 -57504 96766 2187 20133 40785 45497 -3231 -18542 -...
output:
84991
result:
ok single line: '84991'
Test #21:
score: 0
Accepted
time: 52ms
memory: 4464kb
input:
99999 54108 81516 37924 -13600 58451 -99205 -21327 57162 14820 -94006 17684 93711 -45377 267 92147 25669 25509 -20083 -54651 78947 38482 55219 38092 -96988 63173 -38424 32210 29455 -29579 -28592 62124 -48325 -13203 -64248 10129 -16174 -91659 -39364 80003 -91919 -69087 17861 68860 -19778 -67427 70300...
output:
84898
result:
ok single line: '84898'
Test #22:
score: 0
Accepted
time: 52ms
memory: 4516kb
input:
99999 161 56900 -65799 -27891 -21318 14917 49713 -77270 -78189 3790 -70316 -99479 31417 62780 63027 -53348 -52627 -26834 -15011 14776 47610 -80641 -22900 55289 29797 1966 -76355 68217 48960 -51479 1886 20635 -56832 -58818 -56108 25937 37964 41730 16091 92998 78592 97497 -73818 68676 -43625 70324 157...
output:
84836
result:
ok single line: '84836'
Test #23:
score: 0
Accepted
time: 52ms
memory: 4476kb
input:
100000 -58093 -51507 -81910 -55878 -23892 38397 -56430 -70946 -42654 70111 53024 768 -70003 -508 -88199 -96939 34253 48468 -29828 493 63656 3761 -74445 78805 -63797 -57085 -29439 70220 -80214 -20899 -79285 -30371 7753 71111 73388 42624 -30830 -438 -69951 21169 46605 26559 10657 -44076 -98239 -32075 ...
output:
84928
result:
ok single line: '84928'
Test #24:
score: 0
Accepted
time: 14ms
memory: 4436kb
input:
99332 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
output:
0
result:
ok single line: '0'
Test #25:
score: 0
Accepted
time: 49ms
memory: 4440kb
input:
99465 0 1 1 1 1 1 1 1 1 0 1 1 0 1 1 0 1 1 0 1 0 1 1 1 1 0 1 1 1 0 1 0 0 1 0 0 1 0 0 0 0 1 1 1 0 1 0 0 1 0 0 1 1 1 0 0 0 1 1 0 1 0 0 0 0 0 0 0 0 1 0 0 1 0 0 1 1 1 1 0 0 0 0 0 1 1 0 1 0 1 0 1 0 0 1 1 1 0 0 0 0 0 0 0 1 1 0 0 1 0 0 1 1 1 1 0 0 0 0 0 1 0 1 1 0 0 1 0 0 0 0 0 0 1 1 1 1 0 1 0 0 1 0 1 1 0 1 ...
output:
84423
result:
ok single line: '84423'
Test #26:
score: 0
Accepted
time: 0ms
memory: 3768kb
input:
10 30 -96 -26 67 92 56 -72 74 74 96
output:
10
result:
ok single line: '10'
Test #27:
score: 0
Accepted
time: 19ms
memory: 4444kb
input:
99234 1 -1 0 -1 1 0 -1 1 1 -1 0 -1 0 0 -1 -1 1 -1 0 1 0 1 0 -1 1 0 1 1 0 1 -1 -1 0 1 0 1 1 -1 1 -1 1 0 1 -1 0 0 1 1 -1 -1 0 -1 1 0 -1 1 1 1 -1 0 1 -1 1 -1 0 0 1 -1 1 -1 1 -1 -1 0 -1 -1 0 0 0 0 0 1 -1 1 0 1 1 0 1 1 -1 0 -1 0 0 1 0 -1 1 -1 -1 0 -1 1 0 0 -1 -1 -1 -1 1 0 -1 -1 -1 -1 -1 1 0 1 -1 0 -1 0 0...
output:
0
result:
ok single line: '0'
Test #28:
score: 0
Accepted
time: 52ms
memory: 4448kb
input:
99999 9825 -29348 98333 66935 -60839 -80606 3071 -50869 -58426 36190 -8053 85095 -56083 -94646 21870 6105 71044 -18533 -40720 20145 54800 -1684 -80038 1599 -48689 -49242 55861 -16702 -20685 58635 48839 -54542 57638 -98644 -93464 -69122 39363 -80516 85261 25280 -72573 -21840 -56681 -78811 -8303 -2366...
output:
84802
result:
ok single line: '84802'
Test #29:
score: 0
Accepted
time: 46ms
memory: 4508kb
input:
99999 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
output:
84505
result:
ok single line: '84505'
Test #30:
score: 0
Accepted
time: 51ms
memory: 4464kb
input:
100000 0 0 0 -100000 -100000 100000 -100000 0 -100000 -100000 100000 0 100000 -100000 -100000 0 0 100000 -100000 -100000 100000 100000 100000 0 0 100000 0 0 -100000 0 -100000 100000 0 0 0 100000 -100000 0 -100000 -100000 -100000 100000 0 100000 0 0 -100000 100000 0 -100000 0 -100000 0 0 0 0 0 0 -100...
output:
84850
result:
ok single line: '84850'
Test #31:
score: 0
Accepted
time: 0ms
memory: 3684kb
input:
15 60 60 -8 4 56 36 -77 44 28 16 -72 8 89 52 4
output:
13
result:
ok single line: '13'
Test #32:
score: 0
Accepted
time: 0ms
memory: 3688kb
input:
11 -17 -5 -47 -63 55 48 -9 -57 14 -73 -97
output:
9
result:
ok single line: '9'
Test #33:
score: 0
Accepted
time: 1ms
memory: 3680kb
input:
1 0
output:
0
result:
ok single line: '0'
Test #34:
score: 0
Accepted
time: 0ms
memory: 3664kb
input:
1 1
output:
1
result:
ok single line: '1'
Test #35:
score: 0
Accepted
time: 1ms
memory: 3664kb
input:
2 -25 30
output:
2
result:
ok single line: '2'
Test #36:
score: 0
Accepted
time: 0ms
memory: 3616kb
input:
4 -1 9 -9 1
output:
4
result:
ok single line: '4'