当前位置:网站首页>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;
}
边栏推荐
- 六、HikariConfig的配置解析
- RPM package installation command
- JQ implements tab switching
- 6、 Configuration resolution of hikariconfig
- On Oracle full stack virtual machine -- graalvm
- SEO outsourcing reliable company, enterprise SEO outsourcing company which reliable?
- Yum command
- PostgreSQL division considerations
- Embark on a new journey and reach the world with wisdom
- Gbpnzd firm offer for 14 months, simulation for 19 months, test stable
猜你喜欢
Laravel validation rule followed Role of auth:: id()
Embark on a new journey and reach the world with wisdom
Panda weekly -2022/02/18
Paddleocr learning (II) paddleocr detection model training
SEO outsourcing reliable company, enterprise SEO outsourcing company which reliable?
wooyun-2014-065513
Applet wx Request encapsulation
Uncover ges super large scale graph computing engine hyg: Graph Segmentation
ECS 7-day practical training camp (Advanced route) -- day01 -- setting up FTP service based on ECS
DARKHOLE 2
随机推荐
Android Development Notes - Quick Start (from sqllite to room licentiousness) 2
Error record: preg_ match(): Compilation failed: range out of order in character class at offset 13
One night I worked as an XPath Terminator: XPath Helper Plus
Applet canvas generate sharing Poster
RPM package installation command
Network security detection and prevention test questions (V)
Panda weekly -2022/02/18
Applet multi image to Base64 upload
在打新債開戶證券安全嗎?低傭金靠譜嗎
Guangzhou Sinovel interactive VR panorama brings development to all walks of life
Pdf file download (the download name is the same as the file name)
Vulnhub range - correlation:2
2.14(Knight Moves)
Life cycle function of composite API
Determine whether it is a web page opened on wechat
PHP Chinese regular
Mysql database design suggestions
Is it safe to open a new bond? Is low commission reliable
Apifox simple understanding -- the integrator of web side testing
Arduino ide + esp8266+mqtt subscribe to publish temperature and humidity information