随笔分类 -  ACM---Template

摘要:/************************************************************************* root 根节点的 父亲节点 设为NULL ... 阅读全文
posted @ 2014-08-02 17:38 芷水 阅读(214) 评论(0) 推荐(0)
摘要:1 LL Ex_GCD(LL a,LL b,LL &x,LL& y) 2 { 3 if(b==0) 4 { 5 x=1; 6 y=0; 7 return a; 8 } 9 LL g=Ex_GCD(b,a%b,x,y);... 阅读全文
posted @ 2014-07-18 17:01 芷水 阅读(118) 评论(0) 推荐(0)
摘要:1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 const int maxn = 1e6; 8 bitset prime; 9 10 void init()11 {12 int ... 阅读全文
posted @ 2014-07-18 10:50 芷水 阅读(170) 评论(0) 推荐(0)
摘要:1 一维哈希 2 const int MAX=100007; 3 bool Hash[MAX]; 4 int idx[MAX]; 5 int val[MAX]; 6 7 void Insert(int id,int num) 8 { 9 int k=num%MAX;10 while(Hash[k] && val[k]!=num)11 {12 k++;13 if(k==MAX) k=k-MAX;14 }15 if(!Hash[k])16 {17 Hash[k]=1;18 idx[k... 阅读全文
posted @ 2014-03-12 19:57 芷水 阅读(323) 评论(0) 推荐(0)
摘要:1 LL pow1_sum(LL a,LL b,LL mod) //a*b%mod 2 { 3 a=a%mod; 4 b=b%mod; 5 LL cur=0; 6 while(b) 7 { 8 if(b&1) 9 {10 cur=cur+a;11 if(cur>=mod) cur=cur-mod;12 }13 a=a=mod) a=a-mod;15 b=b>>1;16 }17 return cur;18 }19... 阅读全文
posted @ 2014-02-17 21:41 芷水 阅读(128) 评论(0) 推荐(0)
摘要:1 #include 2 #include 3 #include 4 using namespace std; 5 typedef pair a1; 6 map b; 7 int main() 8 { 9 int i,j,k,n,m,x,y,z;10 pair a;11 while(scanf("%d",&n)>0)12 {13 for(i=1;i<=n;i++)14 {15 scanf("%d%d%d",&x,&y,&z);16 a.first=x;17 a.second=y;18 // b[a]=z;19 阅读全文
posted @ 2013-11-27 19:34 芷水 阅读(251) 评论(0) 推荐(0)
摘要:1 /* 2 优先队列 3 */ 4 5 #include 6 #include 7 #include 8 #include 9 #include10 #define HH 1111111111 using namespace std;12 char a[202][202];13 int visit[202][202];14 int n,m;15 int map[4][2]={{1,0},{0,1},{-1,0},{0,-1}};16 struct node17 {18 friend bool operatorn2.p;21 }22 int p;23 int... 阅读全文
posted @ 2013-11-27 19:28 芷水 阅读(233) 评论(0) 推荐(0)