当前位置:网站首页>PAT B1053
PAT B1053
2022-06-25 19:55:00 【Madness makes freedom】
1053 Housing vacancy rate (20 branch )
Without disturbing the residents , One way to calculate the housing vacancy rate is to judge according to the continuous change of electricity consumption of each household . The judgment method is as follows :
During the observation period , If more than half of the daily electricity consumption is below a given threshold e, Then the house is “ May be vacant ”;
If the observation period exceeds a given threshold D God , And satisfy the previous condition , Then the house is “ The vacancy ”.
The household electricity consumption data of a residential area is given , Please make statistics “ May be vacant ” Ratio and “ The vacancy ” ratio , That is, the percentage of houses in the above two states in the total number of houses in residential areas .
Input format :
Enter the first line to give a positive integer N(≤1000), Is the total number of housing units in the residential area ; A positive real number e, Low battery threshold ; Positive integer D, That is, the observation period threshold . And then N That's ok , Each row gives the electricity consumption data of a house in the following format :
K E1 E2 ... EK
among K Is the number of days observed ,Ei For the first time i Days of electricity consumption .
Output format :
Output in one line “ May be vacant ” Ratio and “ The vacancy ” Percentage of the ratio , Separated by a space , After decimal point 1 position .
sample input :
5 0.5 10
6 0.3 0.4 0.5 0.2 0.8 0.6
10 0.0 0.1 0.2 0.3 0.0 0.8 0.6 0.7 0.0 0.5
5 0.4 0.3 0.5 0.1 0.7
11 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1
11 2 2 2 1 1 0.1 1 0.1 0.1 0.1 0.1
sample output :
40.0% 20.0%
( Sample explanation : The first 2、3 Households as “ May be vacant ”, The first 4 Households as “ The vacancy ”, Other households are not vacant .)
Next time anyway , You must see the title clearly , Understand the meaning of each data representation to write code !!!!
If the observation period exceeds a given threshold D God , And satisfy the previous condition , Then the house is “ The vacancy ”.
The electricity level during the observation period is lower than e The number of consecutive days exceeded d;( It's a bit of a detour , That's true , But I know I made myself clear !!!
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
int n,d;
double e;
cin >> n >> e >> d;
int may=0,fact=0;
for(int j=0;j<n;++j)
{
int days;
cin >> days;
int sum=0;//series: continuity , series
for(int i=0;i<days;++i)
{
double use;
cin >> use;
if(use<e)
{
++sum;
}
}
if(sum>days/2)
{
if(days>d)
++fact;
else
++may;
}
}
double may_=(may*100.0)/n,fact_=(fact*100.0)/n;
printf("%.1f%% %.1f%%\n",may_,fact_);
return 0;
}
边栏推荐
- Error record: preg_ match(): Compilation failed: range out of order in character class at offset 13
- SEO outsourcing reliable company, enterprise SEO outsourcing company which reliable?
- Network security detection and prevention test questions (I)
- 五、HikariCP源码分析之初始化分析二
- Mail monitoring cloud script execution progress
- 在打新债开户证券安全吗
- PostgreSQL user role permissions
- Please do not call Page constructor in files
- 2.14(Knight Moves)
- Install spoole
猜你喜欢

Google SEO external chain releases 50+ website platform sharing (e6zzseo)

Google cloud SSH enable root password login

rmi-registry-bind-deserialization

Record Baidu search optimization thinking analysis

Bloom filter

200 OK (from memory cache) and 200 OK (from disk cache)

Hdoj topic 2005 day

PHP synchronizes website content to hundreds of websites to improve SEO ranking

Two types of attribute injection methods

Ali vision AI training camp-day01
随机推荐
Uniapp waterfall flow, applet waterfall flow, very simple, suitable for the whole platform
Lilda Bluetooth air conditioning receiver helps create a more comfortable road life
What should I pay attention to in GoogleSEO content station optimization?
Wechat applet swiper simple local picture display appears large blank
PostgreSQL division considerations
Network security detection and prevention test questions (I)
Connecting PHP to MySQL instances in the lamp environment of alicloud's liunx system
What are Baidu collection skills? 2022 Baidu article collection skills
Please do not call Page constructor in files
Many varieties of EA can be used
Analyse du code source du processus d'acquisition et de connexion hikaricp II
5、 Initialization analysis II of hikaricp source code analysis
Solidity get quarterly time
Mail monitoring cloud script execution progress
SEO outsourcing reliable company, enterprise SEO outsourcing company which reliable?
Tcp/ip test questions (I)
Two types of attribute injection methods
On Oracle full stack virtual machine -- graalvm
JS asynchronism (III. usage of generator and async/await)
Solidity contract address to wallet, wallet address to contract