Myself代码模板

学啊学啊学太阳

template

毒瘤警告

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/* Headers */
#include<cstdio>
#include<cstring>
#include<cctype>
#include<algorithm>
#include<climits>
#include<vector>
#include<queue>
#include<cmath>
/* define */
#define FOR(i,a,b,c) for(int i=a;i<=b;i+=c)
#define DOW(i,a,b,c) for(int i=a;i>=b;i-=c)
#define LFO(i,a,b,c) for(long long i=a;i<=b;i+=c)
#define LDO(i,a,b,c) for(long long i=a;i>=b;i-=c)
/* namespaces */
namespace FastIO{
const int BUFSIZE=1<<20;
char ibuf[BUFSIZE],*is=ibuf,*its=ibuf;
char obuf[BUFSIZE],*os=obuf,*ot=obuf+BUFSIZE;
inline char getch(){
if(is==its)
its=(is=ibuf)+fread(ibuf,1,BUFSIZE,stdin);
return (is==its)?EOF:*is++;
}
inline int getint(){
int res=0,neg=0,ch=getch();
while(!(isdigit(ch)||ch=='-')&&ch!=EOF)
ch=getch();
if(ch=='-'){
neg=1;ch=getch();
}
while(isdigit(ch)){
res=(res<<3)+(res<<1)+(ch-'0');
ch=getch();
}
return neg?-res:res;
}
inline void flush(){
fwrite(obuf,1,os-obuf,stdout);
os=obuf;
}
inline void putch(char ch){
*os++=ch;
if(os==ot) flush();
}
inline void putint(int res){
static char q[10];
if(res==0) putch('0');
else if(res<0){
putch('-');
res=-res;
}
int top=0;
while(res){
q[top++]=res%10+'0';
res/=10;
}
while(top--) putch(q[top]);
}
}
namespace HashArray{
const int MAXS = 1e6+10;
const int EMPTY = INT_MAX;
int Hash[MAXS];
inline void clear(){
FOR(i,1,MAXS,1)Hash[i]=EMPTY;
}
inline int HashFunc(int x){
return x%MAXS;
}
inline int locate(int x){
int orgi=HashFunc(x);
int p=0;
while((p<MAXS)&&(Hash[(orgi+p)%MAXS]!=x)&&(Hash[(orgi+p)%MAXS]!=EMPTY))p++;
return (orgi+i)%p;
}
inline bool insert(int x){
int posi=locate(x);
if(Hash[posi]==EMPTY){
Hash[posi]=x;
return true;
}
else return false;
}
inline bool member(int x){
int posi=locate(x);
if(Hash[posi]==x)return true;
return false;
}
}
using namespace FastIO;
using namespace HashArray;
/* definitions */
const int MAXN = 1e6+10;
const int MOD = 1e9+7;
/* functions */
inline void init(){
#ifndef
do
#endif
}
inline long long mod(long long a,long long b,long long p){
return (a%p+b)%p;
}
inline long long gcd(long long a,long long b){
return (!b)?a:gcd(b,a%b);
}
inline long long lcm(long long a,long long b){
return (a/gcd(a,b))*(b/gcd(a,b))
}
inline long long quick_power(long long a,long long b,long long p){
long long ans=1,tmp=a;
while(b){
if(b&1)ans=ans*tmp%p;
tmp=tmp*tmp%p;
b>>=1;
}
return ans;
}
inline bool is_prime(long long x){
if(x==1)return false;
else if(x==2||x==3||x==5||x==7||x==11||x==13)return true;
else{
LFO(i,2,sqrt(n)+1,1){
if(x%i==0)return false;
else ;
}
}
return true;
}
int main(int argc,char *argv[]){
#ifndef Herself32_FILE
do
#endif
return 0;
}