摘要: 蛋碎的一道题目就就这样通过了啊其中用了ans来表示地形,0表示平地,z种可能,其中用flag来表示第i种是否满足左右都没有炮i&ans表示这种建炮方式是否符合地形,我后面在这里出了问题,结果发现是在建ans时出了问题,因为如果用1来表示平地,这样的话9&(pphh)>0但是如果用0来表示平地的话,9&(pphh)!=0,只有等于0,他才是符合地形的建炮方法#include "iostream"#include "algorithm"using namespace std;int num[3048],flag[3048],n, 阅读全文
posted @ 2013-09-09 09:28 龙城星 阅读(221) 评论(0) 推荐(0) 编辑
摘要: 终于通过了啊,代码有些长,不过它是我自己做的第一道状态压缩题目,自主创作的#include "iostream"#include "string.h"#include "algorithm"using namespace std;int dp[15][177147];int n,map[15][15];bool init(int a){ for(int i=0;i0){ if(map[0][i]==0)return 0; if(i==n-1)return 1; if((a&(10)return 0; } } return 1; 阅读全文
posted @ 2013-09-06 15:04 龙城星 阅读(208) 评论(0) 推荐(0) 编辑
摘要: 这道题目跟之前做过的关于什么波系数很像,因为之前做过了,现在也就不做了f[1]=1; f[2]=2; f[3]=2; f[4]=4; f[5]=6;......f[n]=f[n-1]+f[n-2];当然因为数据比较大,所以这些数据都要用字符串来表示 阅读全文
posted @ 2013-09-05 09:15 龙城星 阅读(118) 评论(0) 推荐(0) 编辑
摘要: 这是一道很好的题目,我不会做,所以答案是从网上弄的。把人家的代码又重新写了一遍,发现他的也是错的——可能跟编译器有关,但是为什么提交的时候可以通过呢???神奇就因为dp[i][j]这个错了通过的代码#include#includeusing namespace std;const int mm=10) { if(i==w-1||(x&(10) { if((b&(10)i++; else return 0; } return 1;}int main(){ while(cin>>w>>h) { ... 阅读全文
posted @ 2013-09-05 08:55 龙城星 阅读(167) 评论(0) 推荐(0) 编辑
摘要: 看了题解的,有个高手跟我说这道题目要用到dp统计,把原点偏移,即把不能表示的部分移到能够表示的区域。这个想法可能是用在-7500那里我的一开始的想法是dp[i][j] 其中i表示i码,j表示j钩,dp表示是否平衡,但是无论怎么想都觉得这道题目不是dp,而是搜索,所以最后做不出来看了人家的题解,才发现,我的决策变量找错了dp[i][j] 其中i表示i码,j表示天平此时的平衡度,dp表示数量,而且值得注意的是,平衡度有可能是-7500,所以要用到dp偏移理解了人家的想法,我也自己打了一个代码,可是错误了dp[i][j+w[i]*c[k]+7500]+=dp[i-1][j+7500];老是把w跟c给 阅读全文
posted @ 2013-09-03 18:26 龙城星 阅读(126) 评论(0) 推荐(0) 编辑
摘要: 感觉我的代码是没有错的,哈哈哈....其中abs不知道老是用不了,结果只能用最土的方法了啊a>b?a:b;但是没有通过#include "iostream"#include "cmath"#include "algorithm"using namespace std;struct student{ int x,y,count,time;}num[10000];struct{ int time,count;}dp[10000];int cmp(student a,student b){ return a.count>b.co 阅读全文
posted @ 2013-08-30 14:24 龙城星 阅读(121) 评论(0) 推荐(0) 编辑
摘要: 我也不知道我的代码错在哪里#include "iostream"using namespace std;struct{ int n,p;}thing[10000];int main(){ int ncase,n,i,j,num,total; cin>>ncase; while(ncase--){ cin>>n; for(i=1;i>thing[i].n>>thing[i].p;} num=0;total=0; for(i=1;ithing[i].n*thing[i+1].p&&i!=n){ num+=thing[i] 阅读全文
posted @ 2013-08-30 09:54 龙城星 阅读(145) 评论(0) 推荐(0) 编辑
摘要: 看题目时忽略了一个条件,就是只能从1 到2,不可以从2到1,其实这个原本就应该排除掉的,可是我还在犹豫这个用不用考虑接着弄上我的代码,不过presentance error#include "iostream"#include "string.h"using namespace std;int main(){ int ncase,top=1,map[110][110],dp[110],num[110],n,i,m,a,b,j,list[110],path[110]; cin>>ncase; while(ncase--){ cin>> 阅读全文
posted @ 2013-08-28 19:34 龙城星 阅读(324) 评论(0) 推荐(0) 编辑
摘要: 之前卡了我很久,结果今天一看,原来是最长相同序列,这坑爹的,被题目吓到了啊不过呢,我还是不知道自己错在哪里,网上跟差不多的代码,结果我错了啊还有没有出示数据的题目都是耍流氓....耍流氓作为一道最长相同序列,我做错了,关键的两个for我都是从0开始的,不过在数据上是通过了啊,结果呢,wrong answer#include "iostream"#include "string.h"using namespace std;int max(int a,int b){return a>b?a:b;}int dp[2005][2005];int main( 阅读全文
posted @ 2013-08-28 17:11 龙城星 阅读(284) 评论(0) 推荐(0) 编辑
摘要: 题意没有理解透,结果不知道怎么做,据说是很简单的dp问题高手的代码——ACCEPT#include //DP#include #includeusing namespace std;char g[40][40];long long ans[40][40]; //题目要求是64位int main(){ int n; while(cin>>n,n!=-1) { for(int i=1;i<=n;++i) scanf("%s",g[i]+1); memset(ans,0,sizeof(ans)); ... 阅读全文
posted @ 2013-08-28 14:18 龙城星 阅读(149) 评论(0) 推荐(0) 编辑