话说昨天比赛终于拿到一个不错的名次,rank77,对于我们这种ACM弱菜的学校来说已经很好了,可惜我1003用了俩floyd超时,如果我最近稍微搞搞图论的话,用个bellman,或者SPFA,绝对超不了了就。。。哎。。他们的1002貌似也差点出来。。。还有1004被坑人的wa了两次。。。。
理工大的孩子们看到之后,一定好好整理下,不管是这场比赛,还是前几场,比完之后整理再做这些题比较重要。这次比赛的题都不是出不来的,大家加油了。。。
第一题:小Q系列故事——最佳裁判
链接:http://acm.hdu.edu.cn/showproblem.php?pid=4520
题解:水题啊。。懒得看。。贴大牛毕鲁阳的代码
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
using namespace std;struct cp
{int num;double p;
} P[22];
int cmp(cp a, cp b)
{return a.p > b.p ? 1 : 0;
}
int main()
{int n;double sum = 0 ;double ave;int ans;double m;while(scanf("%d",&n),n){sum = 0;m = 999999999;for(int i = 0; i < n; i++){scanf("%lf",&P[i].p);P[i].num = i+1;}sort(P, P+n,cmp);for(int i = 1; i < n-1; i++){sum += P[i].p;}ave = sum / (n-2);for(int i = 0; i <n; i++){if(abs(P[i].p-ave)<m){m = abs(P[i].p-ave);ans = P[i].num;}}printf("%d\n",ans);}return 0;
}
第二题:小明系列问题——小明序列
链接:http://acm.hdu.edu.cn/showproblem.php?pid=4521
题解:
第三题:湫湫系列故事——过年回家
链接:http://acm.hdu.edu.cn/showproblem.php?pid=4522
题解:
第四题:威威猫系列故事——过生日
链接:http://acm.hdu.edu.cn/showproblem.php?pid=4523
题解:两个地方要注意,第一就是我一开始没看到数据量wa了一次。。。10^100 我还用int。。真惊了。。当时只图快了。。结果这下就是20分钟。。哎。。。第二点要注意就是。。杭电相当坑人的M。。他的范围是 M>0 的!!!这就意味着当M为1或者2的时候。。。n和p无论是多少都分割不出来1边形和2边形。。。。又WA一次。。。哎。。欲速则不达啊!!一共罚了40分钟。。。
import java.math.BigInteger;
import java.util.Scanner;public class main {public static void main(String[] args) {BigInteger n, m, p;Scanner cin = new Scanner(System.in);while (cin.hasNextBigInteger()){n = cin.nextBigInteger();m = cin.nextBigInteger();p = cin.nextBigInteger();BigInteger tmp1 = n.add(p);BigInteger tmp2 = BigInteger.valueOf(3);if (tmp1.compareTo(m) < 0 || m.compareTo(tmp2) < 0)System.out.println("NO");elseSystem.out.println("YES");}}
}
第五题:郑厂长系列故事——逃离迷宫
链接:http://acm.hdu.edu.cn/showproblem.php?pid=4524
题解:一开始没看懂题意,好郁闷,我理解能力的确有点问题,题目的意思,右边倒数第一个格子和倒数第二个格子必须同时消失,否则郑厂长就无法进行操作。。。就是这里有点坑。。其他都没什么难的。。
#include <iostream>
using namespace std;
int main()
{int t;scanf("%d", &t);while (t--){int n;scanf("%d", &n);bool flag = true;int i, tmp, num=0;for (i=0; i<n; i++){scanf("%d", &tmp);if (i==n-1 && tmp != num) flag = false;if (tmp < num) flag = false;else num = tmp - num;}if (flag)puts("yeah~ I escaped ^_^");elseputs("I will never go out T_T");}return 0;
}