摘要: 题目:hdu 1143 Tri Tiling思路:dp[i]=3*dp[i-3]+2*(dp[i-4]+dp[i-6]+...+dp[2]+dp[0]);import java.math.BigDecimal;import java.math.BigInteger;import java.util.Scanner;public class Main{ public static void main(String args[]) { Scanner cin=new Scanner(System.in); long dp[]=new long[31]; ... 阅读全文
posted @ 2013-11-15 15:28 over_flow 阅读(131) 评论(0) 推荐(0) 编辑
摘要: 题目:hdu 1041 Computer Transformation思路:打表,找规律#include #include #include #include #include using namespace std;string solve(string s){ string str=""; for(int i=0;i<s.size();i++) if(s[i]=='0') str+="10"; else str+="01"; return str;}int get(string s){ int ... 阅读全文
posted @ 2013-11-15 14:56 over_flow 阅读(212) 评论(0) 推荐(0) 编辑
摘要: 题目:http://acm.hdu.edu.cn/showproblem.php?pid=3466思路:贪心对当前能取的,q-p较小的优先考虑#include #include #include #include #include #include using namespace std;#define maxn 500005int dp[maxn];struct thing{ int p,q,v;}t[510];bool cmp(thing a,thing b){ return (a.q-a.p)=t[i].p;j--) if(j>=t[i].q) ... 阅读全文
posted @ 2013-07-29 15:53 over_flow 阅读(140) 评论(0) 推荐(0) 编辑
摘要: 题目:http://acm.hdu.edu.cn/showproblem.php?pid=2639思路:01背包 第K优解#include #include #include #include #include #include using namespace std;int N,V,K;int f[1010][35];int A[35],B[35];int v[110],w[110];int main(){ int t; scanf("%d",&t); while(t--) { scanf("%d%d%d",&N,&V,& 阅读全文
posted @ 2013-07-29 15:21 over_flow 阅读(154) 评论(0) 推荐(0) 编辑
摘要: 题目:http://poj.org/problem?id=2184负体积的01背包,将原点偏移一下,空间变大了#include #include #include #include #include #include #include #define maxn 200010using namespace std;int s[110],f[110];int dp[maxn];const int miao=100000;int main(){ int n; scanf("%d",&n); int sum=0; for(int i=1;i0) for(i... 阅读全文
posted @ 2013-07-29 14:50 over_flow 阅读(156) 评论(0) 推荐(0) 编辑
摘要: 题目:http://acm.hdu.edu.cn/showproblem.php?pid=2955思路:裸的01背包已知被抓的概率,因为不是相互独立的,一次被抓就不用讨论了,所以我们讨论不被抓的最大概率。#include #include #include #include #include using namespace std;double dp[10010],P,p[110];int money[110];int main(){ int t; scanf("%d",&t); while(t--) { int n; scanf("%lf%... 阅读全文
posted @ 2013-07-28 00:46 over_flow 阅读(136) 评论(0) 推荐(0) 编辑
摘要: 题目:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=503思路:裸的01背包#include #include #include #include #include using namespace std;#define maxn 50010int dp[maxn];int coin[110];int main(){ int t; scanf("%d",&t); while(t--) { int n; 阅读全文
posted @ 2013-07-28 00:21 over_flow 阅读(142) 评论(0) 推荐(0) 编辑
摘要: 题目:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=8&page=show_problem&problem=565思路:裸的01背包,输出路径,用一维数组标记的#include #include #include #include #include #include using namespace std;int minute[25];int dp[10010];int cnt[10010];int main(){ int n,m; stacks; wh 阅读全文
posted @ 2013-07-28 00:03 over_flow 阅读(126) 评论(0) 推荐(0) 编辑
摘要: 题目:http://acm.hdu.edu.cn/showproblem.php?pid=3826思路:如果存在某个大于10^6的质因子,那么顶多存在两个,不然就超longlong了,所以在允许的范围内解决问题还是蛮简单的#include #include #include #include #include using namespace std;#define maxn 1000010bool vis[maxn];int n_prime=0;int prime[78510];int cnt[78510];void Prime(){ memset(vis,true,sizeof(vis... 阅读全文
posted @ 2013-07-25 21:46 over_flow 阅读(190) 评论(0) 推荐(0) 编辑
摘要: 题目:118A - String Task思路:water#include #include #include #include #include #include #define MAXN 100000using namespace std;char s[12]={'a','o','y','e','u','i','A','O','Y','E','U','I'};bool is_ok(char c){ f 阅读全文
posted @ 2013-07-24 17:28 over_flow 阅读(143) 评论(0) 推荐(0) 编辑