摘要:地址:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=615题意:有1,5,10,25,50这五种硬币。给一个价值,求有多少种组合可以得到该价值。mark:完全背包。代码:最近学习一些大牛设计状态的思路,首先想到了用dp[i][0]代表体积为i最多的价值,dp[i][1]代表体积为i最多的方法。#include <cstdio>#include <cstring>#include <cstdlib&g
阅读全文
摘要:地址:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=565题意:背包问题,最多装多少。mark:本题要求输出装的每一个价值,需要回溯一下,必须用二维的。代码:#include <cstdio>#include <cstring>#include <cstdlib>#include <cmath>#include <iostream>#include <algori
阅读全文
摘要:地址:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1047题意:大数乘法代码:#include <stdio.h>#include <string.h>#include <stdlib.h>char a[260],b[260];int x[260], y[260], mut[610];int main(){ while(~scanf("%s%s", a, b)) { me
阅读全文
摘要:地址:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=97&page=show_problem&problem=365题意:求大数a+b代码:#include <stdio.h>#include <string.h>#include <stdlib.h>char a[200], sum[200];int main(){ int le,i,j,k; memset(sum, '0', sizeof(sum))
阅读全文
摘要:地址:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1012题意:给定t时刻速度v,求2t时刻位移。mark:化简位移公式。代码:#include <stdio.h>int main(){ int a,b; while(~scanf("%d%d", &a, &b)) printf("%d\n", 2*a*b); return 0;}
阅读全文
摘要:地址:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=996题意:给军官和敌人的士兵数,求两个人士兵数的差值。mark:UVa第一题,wa了5次。。学到两点! 1.unsigned [0,2^32-1],signed [-2^31, 2^31-1]。 2.vice versa 翻译为 反之亦然。代码:#include <stdio.h>int main(){ long long a,b; while(scanf(&qu
阅读全文