摘要: 思路:dp,转移方程 dp[i] = min(dp[i-1] + 1, dp[i - j*j] + 1);这个转移方程很好理解,类似0-1背包,买j*j的这块地还是不买。跟POJ_3267 The Cow Lexicon很像。ps:上午wa了好几次,下午昨晚福州的网赛又拿过来这个题,不知道改了哪地方,没积分钟就ac了。看来是老天可怜我网赛被虐。。。T_TMy Code:#include <iostream>#include <cstdio>#include <cstring>#include <math.h>using namespace std 阅读全文
posted @ 2011-10-07 19:22 AC_Von 阅读(261) 评论(0) 推荐(0) 编辑
摘要: 表示cin很不靠谱,10^5的数据量都能TLE 改成scanf 300+ms。My Code:#include <iostream>#include <algorithm>#include <cstdio>#include <fstream>using namespace std;const int N = 100005;class phage{public: int di; int ti;}p[N];bool cmp(phage a, phage b){ if(a.ti != b.ti) return a.ti > b.ti; else 阅读全文
posted @ 2011-10-07 19:05 AC_Von 阅读(195) 评论(0) 推荐(0) 编辑
摘要: 昨晚想着做了的,到宿舍乱的又没心情了。发现高精度真的不熟,各种错误,Crash, MLE, WA。。。最后看到有人一个数组空间存两位数,精度为100时才不MLE。#include <iostream>#include <cstdio>#include <cstring>using namespace std;const int N = 1000;int ans[N*2][N+1];int tmp[N+1];void add(int a[], int b[], int res[]){ int i; for(i = N; i >= 0; i--){ res 阅读全文
posted @ 2011-10-07 09:27 AC_Von 阅读(235) 评论(0) 推荐(0) 编辑