摘要: 看题目时忽略了一个条件,就是只能从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) 编辑
摘要: 我一开始是打算通过看数据,查找规律的,但是觉得这样很麻烦,即使看出来,那也没有掌握到其中的思想,加之没有思路,所以我干脆看了人家的答案人家的题解其实本题函数递归都给我们了。但是就是说,要用一般简单的函数的话,就会超时(我试过。)然后我参考了别人博客构造一个三维数组"int d[a][b][c]",用来记忆。真的用到的是后面“ if(d[a][b][c]) return d[a][b][c];”只要曾经算过得就可以记下了。减少了计算时间了!#include "iostream"#include "string.h"using names 阅读全文
posted @ 2013-08-28 13:47 龙城星 阅读(184) 评论(0) 推荐(0) 编辑
摘要: 完完全全地一道水题,以后不做这种题目了,用十几行就可以解决的问题啊#include "iostream"#include "string.h"using namespace std;int main(){ int ncase,n,i; cin>>ncase; while(ncase--){ cin>>n; for(i=2;;i++){ if((i+1)*(i+1)-1>=n){ cout<<i<<endl; break; } } }} 阅读全文
posted @ 2013-08-28 11:01 龙城星 阅读(103) 评论(0) 推荐(0) 编辑
摘要: 又是一道坑爹的题目,明明数据都通过了,就是wrong anser#include "iostream"#include "string.h"using namespace std;struct { int x,index;}dp[1000];int find(int low,int high,int a){ while(low=a)low=mid+1; else high=mid-1; } return low;}int main(){ int n,i,num[1000],k,x,set[1000],len,longth; while(cin>&g 阅读全文
posted @ 2013-08-28 10:13 龙城星 阅读(152) 评论(0) 推荐(0) 编辑