SQYBI.com

Change is a part of life, and takes part in finding us who we are.

2008年08月22日
by sqybi
0 comments

UVa 102 -- Ecological Bin Packing

水题,枚举即可. 第一次提交WA,没有注意这道题并不是Special Judge,如果有多组顺序符合要求,需要输出字典序最靠前的一组. 虽然用了string,不过代码写的还是很垃圾. /* UVa 102; Ecological Bin Packing - sqybi's code */ //for my winsty #include #include using namespace std; const int nn = 3; int t, res, now; int a[nn][nn]; bool u[nn]; char ch[nn] = {'B', 'G', … Continue reading

2008年08月22日
by sqybi
5 Comments

UVa 100 -- The 3n + 1 problem

经典的3n+1,没有想到这道题调了一个晚上. 在Project Euler上看过这道题,于是按照那道题写了个部分DP.然后诡异的WA了. 调啊,调啊,只找到了一个trick:输入的两个数不一定小数在前大数在后. 然后呢,我这个程序是search,可加了一个预处理,for i=1~10000 do dp[i]=f(i),然后调用f(i)的地方改成dp[i],就过不了,都鬼了...怀疑数据范围有问题. search可以1s过掉. /* UVa 100; The 3n + 1 problem - sqybi's code */ //for my winsty //#define DEBUG #include using namespace std; const int nn = 1000001, mm = 10001; int l, … Continue reading