上一页 1 ··· 22 23 24 25 26 27 28 29 30 ··· 47 下一页

2012年6月12日

摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2795下午做的题,线段树单点更新广告牌高h宽w,尽可能在高处挂广告。注意h可能很大,但是我们注意到h比n大就没有意义了,这时我们让h=n(开始因为这个re了)View Code #include <iostream>using namespace std ;#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1const int maxn=200002 ;int h,w,n ;int MAX[maxn<<2] ;void 阅读全文
posted @ 2012-06-12 21:10 LegendaryAC 阅读(87) 评论(0) 推荐(0) 编辑

2012年6月11日

摘要: http://acm.hdu.edu.cn/showproblem.php?pid=3787水View Code #include <iostream>using namespace std ;int pow(int a,int b){ int s=1 ; for(int i=0;i<b;i++) s*=a ; return s ;}int main(){ char a[30],b[30] ; int a1,b1 ; while(~scanf("%s%s",a,b)) { int cnt=0 ; a1=b1=0... 阅读全文
posted @ 2012-06-11 21:41 LegendaryAC 阅读(158) 评论(0) 推荐(0) 编辑

2012年6月10日

摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2151水View Code #include <stdio.h>#include <string.h>int n,p,m,t ;int dp[110][110] ;int main(){ while(~scanf("%d%d%d%d",&n,&p,&m,&t)) { memset(dp,0,sizeof(dp)) ; dp[0][p]=1 ; for(int i=0;i<=m;i++) for(int j=1;j<=n;j 阅读全文
posted @ 2012-06-10 19:35 LegendaryAC 阅读(130) 评论(0) 推荐(0) 编辑
 
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2973威尔逊定理,详情参见数论四大定理。从这道题应用的层面讲,我们只需要知道若p为素数,则p可整除(p-1)!+1。有上面的结论这道题就解决了,3k+7为素数则答案加1,为非素数则不变。(代数式简单变化一下很容易看出来,此处不赘述)为了防止超时,提前把答案打表打出来就好。输入输出挂,果断刷到第一。View Code #include <iostream>using namespace std ;bool prime[3000008] ;int ans[1000001] ;inline bool s 阅读全文
posted @ 2012-06-10 02:59 LegendaryAC 阅读(397) 评论(0) 推荐(0) 编辑
 
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1395枚举x复杂度可以处理成O(n),由于我是个sb,所以给弄成O(nlogn)了。这里用的方法基于欧拉定理。欧拉定理表明,若n,a为正整数,且n,a互质,(a,n) = 1,则a^φ(n) ≡ 1 (mod n)。我们处理的当然是(2,n)=1的情况,枚举欧拉函数的因子即可View Code #include <stdio.h>__int64 qpow(int a,__int64 b,int r){ __int64 ans=1,buff=a; while(b) { if(b&... 阅读全文
posted @ 2012-06-10 00:55 LegendaryAC 阅读(232) 评论(0) 推荐(0) 编辑

2012年6月9日

摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1905水题,套个米勒拉宾的模板就秒了View Code #include <stdio.h>__int64 qpow(int a,int b,int r)//快速幂 { __int64 ans=1,buff=a; while(b) { if(b&1)ans=(ans*buff)%r; buff=(buff*buff)%r; b>>=1; } return ans;}bool Miller_Rabbin(int n,int a)//米勒拉宾... 阅读全文
posted @ 2012-06-09 16:54 LegendaryAC 阅读(191) 评论(0) 推荐(0) 编辑
 
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1140根据球的切点做简单的判断,一开始找到答案没有跳出循环,各种错。。。View Code #include <iostream>#include <cmath>using namespace std ;const double PI=acos(-1.0) ;//π的表示方法 struct point { double x,y,z ;} ;double dis(point p1,point p2){ return sqrt((p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p 阅读全文
posted @ 2012-06-09 05:49 LegendaryAC 阅读(189) 评论(0) 推荐(0) 编辑
 
摘要: struct point{ double x,y ;} ;double direction(point p1,point p2,point p){ return (p.x-p1.x)*(p1.y-p2.y)-(p1.x-p2.x)*(p.y-p1.y) ;}bool online(point p1,point p2,point p){ return (p.x=min(p1.x,p2.x) && p.y=min(p1.y,p2.y)) ;}bool intersect(point p1,point p2,point p3,point p4){ double d1=dire... 阅读全文
posted @ 2012-06-09 03:45 LegendaryAC 阅读(144) 评论(0) 推荐(0) 编辑
 
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1086判断两线段是否相交,用向量搞了View Code #include <iostream>using namespace std ;struct point{ double x,y ;} ;typedef struct L{ point p1,p2 ;}L ;L kk[110] ;double direction(point p1,point p2,point p){ return (p.x-p1.x)*(p1.y-p2.y)-(p1.x-p2.x)*(p.y-p1.y) ;}bool ... 阅读全文
posted @ 2012-06-09 03:41 LegendaryAC 阅读(179) 评论(0) 推荐(0) 编辑

2012年6月8日

摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1240给这道题跪了,z是x,x是y,y是z,囧View Code #include <iostream>using namespace std ;char map[15][15][15] ;int dp[15][15][15] ;int q[15*15*15][3] ;int n ;int sx,sy,sz ;int ex,ey,ez ;void bfs(){ int x,y,z,xx,yy,zz ; int front=0,rear=1 ; int tab[][3]={1,0,0,-1,0... 阅读全文
posted @ 2012-06-08 01:10 LegendaryAC 阅读(258) 评论(0) 推荐(0) 编辑
上一页 1 ··· 22 23 24 25 26 27 28 29 30 ··· 47 下一页