2014年4月30日
摘要: 思路:用a[i]记录i出现的次数,这样就可以避免因大量查找而超时#include#includeint a[1000000];int main(){ int n,i,j,max; while(~scanf("%d\n",&n)) { memset(a,0,sizeof... 阅读全文
posted @ 2014-04-30 18:34 wangzhili 阅读(85) 评论(0) 推荐(0) 编辑
摘要: 思路:一开始拿到这个题目以为是找规律,有递推关系什么的,最后找了好长时间没找到规律,上网查了一下才发现是用母函数做,就是把数的加法和指数乘法的幂的加法联系起来,母函数:G(x)=(1+x+x^2+x^3+x^4+.....)*(1+x^2+x^4+x^6+....)*(1+x^3+x^6+x^9+.... 阅读全文
posted @ 2014-04-30 18:34 wangzhili 阅读(69) 评论(0) 推荐(0) 编辑
摘要: 思路:简单动态规划,多重背包转化成0 1背包问题#include#includeint a[101][2001],rcw[2001],rcp[2001];int max(int x,int y){ return x>y?x:y;}int main(){ int C,i,j,k,pg,n,... 阅读全文
posted @ 2014-04-30 18:34 wangzhili 阅读(74) 评论(0) 推荐(0) 编辑
摘要: 思路:简单的动态规划,0-1背包问题#include#includeint a[1001][1001],va[1001],vo[1001];int max(int x, int y){ return x>y?x:y;}int main(){ int T,i,j,n,v; scanf... 阅读全文
posted @ 2014-04-30 18:34 wangzhili 阅读(89) 评论(0) 推荐(0) 编辑
摘要: 水题,结构题二级排序,在对编号进行逆序排序#include#include#includetypedef struct { float sa; int nu;}Node;Node logo[105];int temp[105];int comp1(const void *a,const ... 阅读全文
posted @ 2014-04-30 18:34 wangzhili 阅读(89) 评论(0) 推荐(0) 编辑
摘要: 思路:数学题,把每个数字对应的行号(1,2,3。。。。。)算出来,行号h = sqrt(n)为整数则不加1,否则加1,得到的就是行号,再分别算出从左边和从右边起的列号(1,2,3。。。),右列号rl = (h*h-n)/2+1,左列号ll = (n-((h-1)*(h-1)+1))/2+1,然后两个... 阅读全文
posted @ 2014-04-30 18:34 wangzhili 阅读(105) 评论(0) 推荐(0) 编辑
摘要: #includeint main(){ int a,c,n,i,j,low,high,sum,max,con = 0; scanf("%d",&c); while(c--) { con++; sum = 0; low = high =... 阅读全文
posted @ 2014-04-30 18:34 wangzhili 阅读(68) 评论(0) 推荐(0) 编辑
摘要: #include#includechar str[10001];int main(){ int T,i,cnt,len; char *p,*q; scanf("%d",&T); while(T--) { cnt = 1; scanf("%s"... 阅读全文
posted @ 2014-04-30 18:34 wangzhili 阅读(66) 评论(0) 推荐(0) 编辑
摘要: 首先,若想使余额最少应该从这m元中首先取出5元用来买最贵的菜,剩下的m-5元就是求在剩下n-1种的菜中的最大花销了,状态转移方程式 :moy[i][j] = max(moy[i][j-1],moy[i-a[j]][j-1]),moy[i][j]表示预算为i时,试买第j个菜的最大花销#include#... 阅读全文
posted @ 2014-04-30 18:34 wangzhili 阅读(98) 评论(0) 推荐(0) 编辑
摘要: 取a的最后一位0-9,发现乘方个位数有周期关系(可以证明不大于4),找到周期和周期里对应的数,对于b直接查找即可#includeint T[5];int main(){ int a,b,i,j,temp,t,d; while(~scanf("%d%d",&a,&b)) { ... 阅读全文
posted @ 2014-04-30 18:34 wangzhili 阅读(87) 评论(0) 推荐(0) 编辑