摘要: 1.C/C++2.Linux/unix3.数据库4.嵌入式 阅读全文
posted @ 2012-03-07 21:33 知行执行 阅读(176) 评论(0) 推荐(0) 编辑
摘要: View Code 1 /* 2 推出:f[n]=2*f[n-1]+1; 3 f[1]=1; 4 可得:f[n]=2^n-1; 5 */ 6 #include<iostream> 7 #include<cstdio> 8 using namespace std; 9 10 const int x=1000000;11 void gao(int n)12 {13 long long s=1,t=2;//注意范围 14 for(;n;n>>=1,t=(t%x)*(t%x),t%=x)15 if(n&1)16 {17 s%=x;18 ... 阅读全文
posted @ 2012-02-21 12:56 知行执行 阅读(140) 评论(0) 推荐(0) 编辑
摘要: 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) 编辑
摘要: View Code 1 #include<iostream> 2 #include<cstdio> 3 using namespace std; 4 5 int a[3400000]={0}; 6 int main() 7 { 8 int m,n,i,t; 9 scanf("%d%d",&m,&n);10 for(i=0;i<m;++i)11 {12 scanf("%d",&t);13 a[t/32] |=(1<<(t%32));//一个int 表示32位 14 } //商相同,余数不同, 阅读全文
posted @ 2012-02-17 20:52 知行执行 阅读(147) 评论(0) 推荐(0) 编辑
摘要: View Code 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<queue> 5 using namespace std; 6 7 struct node 8 { 9 int x,y; 10 }pace[1000]; 11 queue <node> q; 12 bool flag[21][21];//标记各个点是否走过 13 char map[21][100];//迷宫 14 int num[6];//各个门的总钥匙数 15 int ha 阅读全文
posted @ 2012-02-17 19:46 知行执行 阅读(469) 评论(0) 推荐(0) 编辑
摘要: View Code 1 /* 2 思路(借鉴): 3 n!阶乘能分解出几个5,就有几个0 4 因为5与偶数相乘的一个零,偶数是充足的 5 6 */ 7 #include<iostream> 8 using namespace std; 9 int a[10000001];10 int main()11 {12 int i,n,m;13 for(i=1;i<10000001;++i)14 {15 if(i<5){a[i]=0;continue;}16 int k=i/5;// i先分解出一个5,他的商还能分解几个 17 a[i]=k... 阅读全文
posted @ 2012-02-17 13:50 知行执行 阅读(184) 评论(0) 推荐(0) 编辑
摘要: View Code 1 /* 2 观察题目可以发现: 3 划分一个整数 如:n 4 分别是以 n开头,以n-1开头...,以1开头等 5 相当于最大的是开头的那个 其余的数不能超过这个数 6 7 */ 8 9 #include<iostream>10 using namespace std;11 int query(int n,int x)12 {13 if(x<1||n<1)return 0;14 if(x==1||n==1)return 1;15 if(n<x)return query(n,n);//对于n<x说明整数是n 最大也是以n开头 16 if( 阅读全文
posted @ 2012-02-17 11:38 知行执行 阅读(199) 评论(0) 推荐(0) 编辑
摘要: View Code 1 2 /* 3 思路: 4 比如:n=100,m=5 5 100是有20个5组成的 6 因此100减去一个5是95 ,减去两个是90 7 ...减去19个是0. 8 则是5 倍数的数有二十个(不是m的倍数的不能分解出m) 9 ,从这二十个10 数中各分解出一个5则有20个511 这二十个数变为12 20,19,18,...,1即 20的阶乘13 相当于转移到求20的阶乘能分解多少个m了14 依次类推! 15 */16 #include<iostream>17 using namespace std;18 int main()19 {20 int t,n,m;2 阅读全文
posted @ 2012-02-16 08:58 知行执行 阅读(103) 评论(0) 推荐(0) 编辑