Test instructions: give you a sequence, and a standard sequence line, to find the intersection of points.
The best way to do this is to find the number of reverse order, and use array array to optimize it.
Do eight digital time, ask for reverse number search how to beg, but the practice forgot ... So on the spot how to achieve, the results of 1 hours to get out, but also wa a longlong, the foundation is not solid
#include <cstdio>#include<cmath>#include<vector>#include<map>#include<Set>#include<algorithm>#include<cstring>using namespacestd;//#define LOCALtypedefLong Longll;Const intMAXN =1000000+ -;#defineLowbit (x) ((x) &-(x))ll C[maxn];ll n,a,b;voidAdd (ll x,ll d) { while(x <=N) {c[x]+=d; x+=lowbit (x); }}ll sum (ll x) {LL ret=0; while(X >0) {ret+ = C[x]; x-=lowbit (x); } returnret;} ll Count () {ll res=0; ll Ele=b; for(inti =0; I < n; i++) {ll pre= SUM (ele+1); Res+ = Ele-Pre; Add (Ele+1,1); Ele= (ele+a)%N; } returnRes;}intMain () {#ifdef local freopen ("In.txt","R", stdin); //freopen ("OUT.txt", "w", stdout);#endif //Local intCAS =0; while(~SCANF ("%i64d%i64d%i64d", &n,&a,&b) &&N) {memset (C,0,sizeof(C)); printf ("Case %d:%i64d\n",++Cas,count ()); } return 0;}
CF Gym 100463A tree array for inverse number