随笔分类 - 水题
摘要:题目意思简单,思路也挺简单的,可是打代码可不容易,我已经WA一下午了,至今没有AC,希望路过的大牛帮忙测测,将测试数据发给我,我将感激不尽……/* * hdu3925/win.cpp * Created on: 2011-9-20 * Author : ben */#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>using namespace std;const int MAX = 100000000;int ans;char stra[200], strb
阅读全文
摘要:/* * hdu1872/win.cpp * Created on: 2011-9-11 * Author : ben */#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>#include <algorithm>using namespace std;typedef struct { char name[55]; int score;} Student;bool operator<(const Student &s1, const
阅读全文
摘要:判断一个环形的字符串是否对称,其实只需要一一尝试以每一个字符作为中间位置即可。/* * hdu3793/win.cpp * Created on: 2011-9-11 * Author : ben */#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>#include <algorithm>using namespace std;const int MAXN = 105;char str[MAXN];void work();int main() {
阅读全文
摘要:题目很简单,可是打了一个小时,这种题目真是悲剧啊/* * hdu3788/win.cpp * Created on: 2011-9-6 * Author : ben */#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>#include <algorithm>using namespace std;const int MAXN = 1010;bool judge(char *s, int len) { if (len < 3) { retur
阅读全文
摘要:本来以为是求逆序数,要用归并排序,而且还得用线段树动态维护神马的,睁大眼睛一看,我滴妈呀,n才5000,直接暴力过了~~/* * hdu1394/linux.cpp * Created on: 2011-9-6 * Author : ben */#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>#include <algorithm>using namespace std;const int MAXN = 5010;int num[MAXN], r
阅读全文
摘要:本来想用线段树做的,仔细看题发现题目数据太弱了,直接用一个数组标记平面上每一个单位方格即可,水题~/* * hdu1264/linux.cpp * Created on: 2011-9-1 * Author : ben */#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>#include <algorithm>using namespace std;const int MAX_COR = 105;bool map[MAX_COR][MAX_COR
阅读全文
摘要:这种水题都PE了好几次,真是不应该啊!/* * hdu1036/linux.cpp * Created on: 2011-8-31 * Author : ben */#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>#include <algorithm>using namespace std;void work();int main() {#ifndef ONLINE_JUDGE freopen("data.in", &quo
阅读全文
摘要:水题,对输入的每一条信息,都对所有的四位数逐一判断是否符合,记录下即可。/* * hdu1172/linux.cpp * Created on: 2011-8-29 * Author : ben */#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>#include <algorithm>using namespace std;bool maybeans[10005];void work();int main() {#ifndef ONLINE_J
阅读全文
摘要:题目挺简单的,可是就是一直WA,死活查不出来,上网找别人的代码比对,发现思路也没有错误,不得已跟别人的代码逐行比对,最后发现问题在于两处错误,一是比较函数中写错,如果a b 为实数,则return a - b是不对的,因为如果两数之差为小数,可能就舍成整数了,会出问题的,应该用a > b。还有一个问题是求绝对值函数,对于浮点数,应该使用fabs而不是abs
阅读全文
浙公网安备 33010602011771号