雕刻时光

just do it……nothing impossible
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
上一页 1 ··· 36 37 38 39 40 41 42 43 44 ··· 50 下一页

2011年5月4日

摘要: a==ba>b时按: if(a.shu==b.shu) return a.no<b.no; return a.shu<b.shu; a<b时按: if(a.shu==b.shu) return a.no>b.no; return a.shu<b.shu; View Code #include<iostream>#include<cstdio>#include<algorithm>using namespace std;struct data{ int no; int shu;}qun[100009];bool hash[1 阅读全文

posted @ 2011-05-04 21:29 huhuuu 阅读(210) 评论(0) 推荐(0) 编辑

2011年5月3日

摘要: View Code #include<stdio.h>#include<math.h>__int64 gcd(int a,int b){ if(b==0)return a; else gcd(b,a%b);}int main(){ int c,n; while(scanf("%d%d",&c,&n),c&&n) { __int64 add=0; int i; for(i=1;i<=n;i++) { add+=(__int64)pow(c*1.0,gcd(n,i)*1.0); } if(n&1) //翻转的 阅读全文

posted @ 2011-05-03 22:35 huhuuu 阅读(292) 评论(0) 推荐(0) 编辑

2011年5月2日

摘要: 注意点:class base{protected://抽象类成员变量要用protected,而用private子类明显不可以调用 double x;public: base(double a){x=a;} virtual void s()=0;//加个const就不对了 virtual void v()=0;};View Code #include<iostream>using namespace std;class base{protected: double x;public: base(double a){x=a;} virtual void s()=0;//加个const就 阅读全文

posted @ 2011-05-02 19:57 huhuuu 阅读(245) 评论(0) 推荐(0) 编辑

2011年4月28日

摘要: /*******************************************************************************************这里包含了rabinmiller素数测试与pollard算法求解最小质因数的方法,函数说明放到每个函数的前面*******************************************************************************************/不是自己写的学习一下View Code /***************************************** 阅读全文

posted @ 2011-04-28 21:07 huhuuu 阅读(655) 评论(0) 推荐(0) 编辑

摘要: View Code #include<stdio.h>#include<math.h>int prim(int p){ int t=(int)sqrt(1.0*p); int i; for(i=2;i<=t;i++) { if(p%i==0) return 0; } return 1;}int mon(int x,int exp,int p){ if(exp==0) return 1; __int64 ret=mon(x,exp>>1,p); ret=(ret*ret)%p; if(exp&1) { ret =(ret*x)%p; } retu 阅读全文

posted @ 2011-04-28 19:49 huhuuu 阅读(391) 评论(0) 推荐(0) 编辑

2011年4月27日

摘要: 求超级素数的过程比较简单主要是求路径用pa[]随时记录前驱,就好了View Code #include<stdio.h>#include<math.h>int prim[109];int f[109];int pa[109];bool rprim[109];int isprim(int a){ int t=sqrt(a*1.0); int i; for(i=2;i<=t;i++) { if(a%i==0) return 0; } return 1;}int main(){ int n; scanf("%d",&n); int i,add 阅读全文

posted @ 2011-04-27 22:19 huhuuu 阅读(322) 评论(0) 推荐(0) 编辑

2011年4月26日

摘要: 直接用欧几里得AX+BY=gcd(A,B);问题里s(n-m)+k*l=x-y所以存在s,k的整数解的话就要 (x-y)%gcd(n-m,l)再分情况考虑n-m是否是正负 枚举k得出解View Code #include<stdio.h>__int64 gcd(__int64 m,__int64 n){ __int64 t; while(n!=0) { t=m%n; m=n; n=t; } return m;}int main(){ __int64 x,y,m,n,l; while(scanf("%I64d%I64d%I64d%I64d%I64d",&x 阅读全文

posted @ 2011-04-26 21:50 huhuuu 阅读(211) 评论(0) 推荐(0) 编辑

2011年4月23日

摘要: 自己的代码:用到了STL实现:把两个二分集合分别保存在两个set容器里在用queue实现可以对后面有影响的组合先进入set容器View Code #include<stdio.h>#include<set>#include<queue>#include<algorithm>#include<iostream>using namespace std;char hash[209][209];bool x[30009];struct data { int a,b;};int cmp(data x,data y){ return x.a< 阅读全文

posted @ 2011-04-23 10:33 huhuuu 阅读(502) 评论(0) 推荐(0) 编辑

2011年4月21日

摘要: 做规律题是可以先暴力找规律发现规律在11111之类的数附近修改暴力程序继续找做规律题一定要把规律找透再写View Code #include<stdio.h>int main(){ int k; scanf("%d",&k); if(k==1) { printf("8\n"); return 0; } int n=(k-1)%6; if(n==1||n==2||n==4||n==5) printf("1\n"); else if(n==0) printf("4\n"); else printf( 阅读全文

posted @ 2011-04-21 17:02 huhuuu 阅读(177) 评论(0) 推荐(0) 编辑

摘要: 1 2 3 4 5 6 7 8 99 8 7 6 5,4 3 2 15 6 7,8 9,1 2,3 47 6,5,9,8,2,1,4,36,7,5,9,8,2,1,4,3多次倒序Input9 4Output8折中枚举,两种情况,右边的,左边的……View Code #include<stdio.h>int main(){ int n,x,y; scanf("%d%d",&n,&y); int add=0; while(n>=2) { x=n+1-y; if(x>(n+1)/2) { y=x-(n+1)/2; add+=(n+1)/2; 阅读全文

posted @ 2011-04-21 15:58 huhuuu 阅读(186) 评论(0) 推荐(1) 编辑

上一页 1 ··· 36 37 38 39 40 41 42 43 44 ··· 50 下一页