1053 住房空置率 (20 分)
题目链接
算法分析
没什么特别的,按照题目要求做就好,注意不要搞错数据类型就好。
代码实现
#include<bits/stdc++.h>
using namespace std;
int cnt1, cnt2;
int main(){
double x, e;
int n, d;
int k;
scanf("%d%lf%d", &n, &e, &d);
for(int i = 1; i <= n; ++ i){
int cnt = 0;
scanf("%d", &k);
for(int j = 1; j <= k; ++ j){
scanf("%lf", &x);
if(x < e) cnt ++;
}
if(cnt > k / 2){
cnt1 ++;
if(k > d){
cnt2 ++;
cnt1 --;
}
}
}
printf("%.1lf%% %.1lf%%", cnt1 * 100.0 / n, cnt2 * 100.0 / n);
return 0;
}