@@ -8,43 +8,41 @@ using namespace std;
8
8
typedef long long LL;
9
9
typedef long double LD;
10
10
11
- const int MAX = 1e5 + 5 ;
12
- const int LIM = 3e5 + 5 ;
13
- const int MOD = 1e9 + 7 ;
14
- const LD EPS = 1e-10 ;
11
+ const int MAX = 1e5 + 5 ;
12
+ const int LIM = 3e5 + 5 ;
13
+ const int MOD = 1e9 + 7 ;
14
+ const LD EPS = 1e-10 ;
15
15
const double PI = acos(-1.0 );
16
16
17
- #define fastio ios_base::sync_with_stdio (0 );cin.tie(0 );cout.tie(0 )
18
- #define Assert (x ) {if (!(x)){cerr<<" Assertion failed at line " <<__LINE__<<" : " <<#x<<" = " <<(x)<<" \n " ;exit (1 );}}
19
- #define inchar getchar// _unlocked
20
- #define outchar (x ) putchar(x)// _unlocked(x)
21
- #define unique (a ) sort((a).begin(), a.end()), (a).erase(unique((a).begin(), (a).end()),(a).end())
17
+ #define fastio ios_base::sync_with_stdio (0 );cin.tie(0 );cout.tie(0 )
18
+ #define Assert (x ) {if (!(x)){cerr<<" Assertion failed at line " <<__LINE__<<" : " <<#x<<" = " <<(x)<<" \n " ;exit (1 );}}
19
+ #define inchar getchar// _unlocked
20
+ #define outchar (x ) putchar(x)// _unlocked(x)
22
21
23
- # define trace (...) __f(#__VA_ARGS__, __VA_ARGS__)
24
- template <typename Arg1> void __f ( const char * name, Arg1&& arg1){cout<<name<< " : " <<arg1<< " \n " ;}
25
- template < typename Arg1, typename ... Args> void __f ( const char * names, Arg1&& arg1, Args&&... args){ const char * comma= strchr (names+ 1 , ' , ' );cout. write (names,comma-names)<< " : " <<arg1<< " , " ; __f (comma+ 1 , args...) ;}
26
-
27
- double tick (){ static clock_t oldt; clock_t newt= clock (); double diff= 1.0 *(newt-oldt)/CLOCKS_PER_SEC;oldt = newt; return diff ;}
28
- template < typename T> void inPos (T &x){x =0 ;register T c= inchar () ;while (((c< 48 )||(c> 57 ))&&(c!= ' - ' ))c= inchar ();bool neg= false ; if (c== ' - ' )neg= true ; for (;c< 48 ||c> 57 ;c= inchar ()); for (;c> 47 &&c< 58 ;c= inchar ())x=(x<< 3 )+(x<< 1 )+(c& 15 ); if (neg)x=-x;}
29
- template < typename T> void outPos (T n){ if (n< 0 ){ outchar ( ' - ' );n*=- 1 ;} char snum[ 65 ]; int i= 0 ; do {snum[i++]=n% 10 + ' 0 ' ;n/= 10 ;} while (n);i=i- 1 ; while (i>= 0 ) outchar (snum[i--]); outchar ( ' \n ' ) ;}
30
- inline void inStr ( char *str){ register char c= 0 ; register int i= 0 ; while (c< 33 )c= inchar (); while (c!= ' \n ' &&c!= ' ' &&c!=EOF){str[i]=c;c= inchar ();++i;}str[i]= ' \0 ' ;}
31
- template <typename T> T gcd (T a, T b){return (b? __gcd (a,b):a );}
32
- template < typename T> T lcm (T a, T b){ return (a*(b/ gcd (a,b)) );}
33
- template < typename T> T mod (T a, T b) { return (a<b ? a : a%b );}
34
- template < typename T> T add (T a, T b, T c){T x=a+ b;return (x >=c ? x-c : x );}
35
- template < typename T> T mod_neg (T a, T b) {a= mod (a, b) ;if (a <0 ){a+=b;} return a ;}
36
- LL mulmod (LL a,LL b, LL m){LL q=(LL)(((LD)a*(LD)b)/(LD)m);LL r=a*b-q*m; if (r>m)r%=m; if (r< 0 )r+=m; return r ;}
37
- template <typename T> T expo (T e, T n){T x=1 ,p=e;while (n){if (n&1 )x=x*p ;p=p*p ;n>>=1 ;}return x;}
38
- template <typename T> T power (T e , T n , T m ){T x= 1 %m,p=e; while (n){ if (n& 1 )x= mod (x*p,m);p= mod (p*p,m);n>>= 1 ;} return x;}
39
- template < typename T> T extended_euclid (T a, T b, T &x, T &y){T xx= 0 ,yy= 1 ;y= 0 ;x= 1 ; while (b){T q=a/b,t=b;b=a%b;a=t; t=xx;xx=x-q*xx;x=t;t=yy;yy=y-q*yy;y=t;}return a;}
40
- template <typename T> T mod_inverse (T a, T n){T x,y;T d = extended_euclid (a, n, x, y);return (d>1 ?-1 :mod_neg (x,n));}
22
+ double tick (){ static clock_t oldt,newt= clock (); double diff= 1.0 *(newt-oldt)/CLOCKS_PER_SEC;oldt=newt; return diff;}
23
+ template <typename T> void inpos (T &x){x= 0 ; register T c= inchar (); while (((c< 48 )||(c> 57 ))&&(c!= ' - ' ))c= inchar (); bool neg= 0 ;\
24
+ if (c== ' - ' )neg= 1 ; for (;c< 48 ||c> 57 ;c= inchar ()); for (;c> 47 &&c< 58 ;c= inchar ())x=(x<< 3 )+(x<< 1 )+(c& 15 ); if (neg)x=-x ;}
25
+ template < typename T> void outpos (T n){ if (n< 0 ){ outchar ( ' - ' );n*=- 1 ;} char snum[ 65 ]; int i= 0 ; do {snum[i++]=n% 10 + ' 0 ' ;n/= 10 ;}\
26
+ while (n);i=i- 1 ; while (i>= 0 ) outchar (snum[i--]); outchar ( ' \n ' ) ;}
27
+ inline void instr ( char *str){ register char c =0 ;register int i= 0 ;while (c< 33 )c= inchar ();while (c!= ' \n ' &&c!= ' ' &&c!=EOF){\
28
+ str[i]=c;c= inchar ();++i;}str[i]= ' \0 ' ;}
29
+ template < typename T> T gcd (T a, T b){ return (b? __gcd (a,b):a) ;}
30
+ template <typename T> T lcm (T a, T b){return (a*(b/ gcd (a,b)) );}
31
+ int add ( int a, int b, int c){ int res=a+b; return (res>=c?res-c:res );}
32
+ int mod_neg ( int a, int b, int c){ int res; if ( abs (a-b)<c)res=a-b; else res=(a-b)%c; return (res< 0 ?res+c:res );}
33
+ int mul ( int a, int b, int c){LL res=(LL)a* b;return (res >=c?res%c:res );}
34
+ LL mulmod (LL a,LL b, LL m){LL q = (LL)(((LD)a*(LD)b)/(LD)m);LL r=a*b-q*m; if (r>m)r%=m ;if (r <0 )r+=m; return r ;}
35
+ template < typename T>T expo (T e, T n){T x= 1 ,p=e; while (n){ if (n& 1 )x=x*p;p=p*p;n>>= 1 ;} return x ;}
36
+ template <typename T>T power (T e, T n, T m ){T x=1 ,p=e;while (n){if (n&1 )x=mul (x,p,m) ;p=mul (p,p,m) ;n>>=1 ;}return x;}
37
+ template <typename T>T extended_euclid (T a , T b , T &x, T &y ){T xx= 0 ,yy= 1 ;y= 0 ;x= 1 ; while (b){T q=a/b,t=b;b=a%b;a=t;\
38
+ t=xx;xx=x-q*xx;x=t;t=yy;yy=y-q*yy;y=t;}return a;}
39
+ template <typename T>T mod_inverse (T a, T n){T x,y,z= 0 ;T d= extended_euclid (a,n,x, y);return (d>1 ?-1 :mod_neg (x,z ,n));}
41
40
42
41
int main () {
43
- #ifndef ONLINE_JUDGE
44
- freopen (" inp.txt" , " r" , stdin);
45
- #endif
42
+ #ifndef ONLINE_JUDGE
43
+ freopen (" inp.txt" , " r" , stdin);
44
+ #endif
46
45
47
-
48
- // cout<<"Execution time : "<<tick()<<"\n";
49
- return 0 ;
46
+ // cout<<"Execution time : "<<tick()<<"\n";
47
+ return 0 ;
50
48
}
0 commit comments