2015“弱校连萌寒假专题一”:http://acm.bnu.edu.cn/v3/contest_show.php?cid=5772#info
poj题目链接:http://poj.org/problem?id=1877
这题通过率很低但是很简单 看了一下估计是编译器的问题 得交vc++或者c++
估算一下复杂度发现毫无压力 所以就用最简单粗暴的方式了
#include <cstdio> #include <cstring> #include <cstdlib> #include <iostream> #include <algorithm> #include <cmath> #include <set> #include <queue> #include <stack> #include <map> #include <vector> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> P; const int maxn = 20; ll a[1000]; int main() { //freopen("in.txt", "r", stdin); //freopen("out.txt", "w", stdout); for(int t = 1;; t++) { int n, m; ll v; scanf("%d%d", &n, &m); if(n == 0 && m == 0) break; int tot = n*m; for(int i = 0; i < tot; i++) scanf("%lld", &a[i]); scanf("%lld", &v); sort(a, a + tot); int cnt = 0; ll sum = 0; for(int i = 0; i < tot; i++) { if(i == tot - 1) { sum += a[i]; cnt = tot; break; } sum += a[i]; cnt++; if(a[i+1] * 100 * cnt - sum * 100 >= v) break; } double ans = (double)(v + sum * 100) / cnt / 100; printf("Region %d ", t); printf("Water level is %.2f meters. ", ans); printf("%.2f percent of the region is under water. ", (double)cnt/tot*100); printf(" "); } return 0; }