PAT (Basic Level) 1053 住房空置率

题意

emmm,自行读题吧,挺水的。

思路

水~

代码

#include <bits/stdc++.h>
using namespace std;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int n, D;
	double e;
	cin >> n >> e >> D;
	int poss = 0, must = 0;
	for (int i = 0; i < n; ++i) {
		int k;
		cin >> k;
		int cnt = 0;
		for (int j = 0; j < k; ++j) {
			double x;
			cin >> x;
			if (x < e) cnt++;
		}
		if (cnt * 2 <= k) continue;
		if (k > D)
			must++;
		else
			poss++;  
	}
	cout << fixed << setprecision(1) << poss * 100.0 / n << "% ";
	cout << fixed << setprecision(1) << must * 100.0 / n << "%\n";
	return 0;
} 

HINT

不定时更新更多题解,Basic Level 全部AC代码,详见 link ! ! !

发布了72 篇原创文章 · 获赞 15 · 访问量 3252

猜你喜欢

转载自blog.csdn.net/abcdefbrhdb/article/details/104623413