上一页 1 ··· 14 15 16 17 18 19 20 21 22 ··· 47 下一页

2014年2月15日

摘要: 解决一类整数拆分问题void mu(){ memset(c1,0,sizeof(c1)) ; memset(c2,0,sizeof(c2)) ; for(int i=0 ;i<=a[0]*b[0] ;i+=a[0])//a[i]第i项单价 b[i]第i项数量 c1[i]=1 ; for(int i=1 ;i<n ;i++)//n代表总共的单价数量 { for(int j=0 ;j<=sum ;j++)//sum代表幂次上限 { for(int k=0 ;k+j<=sum && k<=a[i]*b[... 阅读全文
posted @ 2014-02-15 19:53 LegendaryAC 阅读(152) 评论(0) 推荐(0) 编辑

2014年2月6日

摘要: http://www.cnblogs.com/jffifa/archive/2012/08/17/2644847.html写得够好了个人习惯从1计数。。无伤大雅。。dp数组最开始memset成-1一次就够了int dfs(int i,int s,int e){ if(!i)return s==target_s ; if(!e && dp[i][s]!=-1)return dp[i][s] ; int u=e?digit[i]:9 ; int res=0 ; for(int d=0 ;d<=u ;d++) res+=dfs(i-1,new_s,e &&... 阅读全文
posted @ 2014-02-06 19:03 LegendaryAC 阅读(131) 评论(0) 推荐(0) 编辑
 
摘要: 模板http://www.cnblogs.com/jffifa/archive/2012/08/17/2644847.html完全理解以后,我发现这种写法实在是太厉害了,简洁,优美,可以回避很多细节问题,而这些细节如果用递推的方法写,处理起来可能会非常痛苦http://acm.hdu.edu.cn/showproblem.php?pid=2089不要62http://www.cnblogs.com/xiaohongmao/p/3473599.html前几天写过这道题的解题报告,两种解法都有http://acm.hdu.edu.cn/showproblem.php?pid=3555不要49#in 阅读全文
posted @ 2014-02-06 18:58 LegendaryAC 阅读(179) 评论(0) 推荐(0) 编辑

2014年1月29日

摘要: d模f的乘法逆元int Extend_Eulid(int d,int f){ int x1,x2,x3,y1,y2,y3 ; x1=1,x2=0,x3=f,y1=0,y2=1,y3=d ; while(y3 && y3!=1) { int q=x3/y3 ; int t1,t2,t3 ; t1=x1-q*y1,t2=x2-q*y2,t3=x3-q*y3 ; x1=y1,x2=y2,x3=y3 ; y1=t1,y2=t2,y3=t3 ; } if(!y3)return -1 ; ret... 阅读全文
posted @ 2014-01-29 07:42 LegendaryAC 阅读(168) 评论(0) 推荐(0) 编辑
 
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1452原来真心没见过这种题,不会做,非常帅gcd(a,b)==1 && s(a,b)==s(a)*s(b)满足这种条件的s叫做积性函数,本题求的因子和就是一个积性函数接着有一个结论if(prime[p])s(p^n)=1+p^1+p^2+p^n=(p^(n+1)-1)/(p-1)s(2004^n)=s(2^(2n))*s(3^n)*s(167^n)其中,167和22关于29同余所以,s(2004^n)=s(2^(2n))*s(3^n)*s(2^n)a=s(2^(2n))=(2^(2n+1)-1 阅读全文
posted @ 2014-01-29 07:41 LegendaryAC 阅读(504) 评论(0) 推荐(0) 编辑

2014年1月26日

摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2665在线询问静态区间k大去学主席树,没看懂;学树套树,没看懂;最后划分树拯救了我,orz......划分树讲解看百度百科#include #include using namespace std ;int tree[30][100005] ;int toleft[30][100005] ;int sorted[100005] ; void build(int l,int r,int dep){ if(l==r)return ; int m=(l+r)>>1 ; int same=m-l+1... 阅读全文
posted @ 2014-01-26 18:07 LegendaryAC 阅读(208) 评论(0) 推荐(0) 编辑

2014年1月23日

摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1806非常玄妙的rmq问题,这个st算法有点神#include #include using namespace std ;int dp[100005][20] ;int a[100005],b[100005] ;void makermq(int n,int *tt){ for(int i=0 ;i>1 ; if(a[mid]>temp) r=mid-1 ; else if(a[mid]=0 ;i--) { if(i=... 阅读全文
posted @ 2014-01-23 21:55 LegendaryAC 阅读(191) 评论(0) 推荐(0) 编辑
 
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1043http://www.cnblogs.com/goodness/archive/2010/05/04/1727141.html根据这篇文章说的八数码八境界,我这种做法大概是在境界三。。我选择的是康托展开作为哈希函数,在全排列问题中这个哈希函数可以很好的处理冲突http://zh.wikipedia.org/zh/%E5%BA%B7%E6%89%98%E5%B1%95%E5%BC%80当然白书上的那种哈希也是极好的。。#include #include #include using namespace s 阅读全文
posted @ 2014-01-23 10:15 LegendaryAC 阅读(649) 评论(0) 推荐(0) 编辑

2014年1月18日

摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1073模拟oj判题随便搞,开始字符串读入的细节地方没处理好,wa了好久#include #include #include #include using namespace std ; char s1[100005... 阅读全文
posted @ 2014-01-18 23:29 LegendaryAC 阅读(289) 评论(0) 推荐(0) 编辑
 
摘要: http://codeforces.com/problemset/problem/382/C读完题立刻知道怎么做,然后分类讨论到吐血,写挂了,巨蠢#include #include #include #include using namespace std ;int n ;int a[100005] ;int temp1,temp2 ;int cnt1,cnt2,p1,p2 ;int gao(){ int f=1 ; cnt1=cnt2=0 ; temp1=a[0]-a[1] ; for(int i=1 ;i=1 ;i--) if(a[i]-a[i-1]!... 阅读全文
posted @ 2014-01-18 02:50 LegendaryAC 阅读(252) 评论(0) 推荐(0) 编辑
上一页 1 ··· 14 15 16 17 18 19 20 21 22 ··· 47 下一页