摘要: View Code 1 #include<iostream> 2 #include<cstdio> 3 #include<queue> 4 using namespace std; 5 priority_queue <int ,vector<int>,greater<int> > q; 6 int main() 7 { 8 int t,n,x,y,sum; 9 int i;10 scanf("%d",&t);11 while(t--)12 {13 while(!q.empty())q.pop() 阅读全文
posted @ 2012-02-18 08:34 知行执行 阅读(250) 评论(0) 推荐(0) 编辑
摘要: 高次方求模:比如a的b次方对c求模我们可以把b 化为二进制形式看那一位有1比如b=10101则 a^b=a^(10000)*a^(100)*a^(1)以函数形式体现:long long a,b,c;void han(){ long long t,s; for(t=a,s=1;b;b>>=1,t*=t,t%=c)//用b>>=1查看b中1 if(b&1){s*=t;s%=c;} printf("%lld\n",s%c); } 阅读全文
posted @ 2012-02-18 07:47 知行执行 阅读(766) 评论(0) 推荐(0) 编辑
摘要: View Code 1 /* 2 高次方求模: 3 比如a 的 b次方 对c 求模: 4 比如:2^10次方,对3求模 5 10的二进制是1010相当于2^10=2^8*2^2 6 我们看对应的二进制位是否为1,若为1则乘上2^i次方 7 若为0则不乘(注意一个规律:第i位2^i=(2^i-1)*(2^i-1)) 8 */ 9 #include<iostream>10 #include<cstdio>11 using namespace std;12 13 long long a,b,c;14 void han()15 {16 long long t,s;17 for( 阅读全文
posted @ 2012-02-18 07:40 知行执行 阅读(164) 评论(0) 推荐(0) 编辑