1053 Python implementation housing vacancy rate

tags: PAT Exercises  Python language  programming

1053 housing vacancy rate (20 points)

Without disturb residents, a method of statistical housing vacancy rate is judged by a continuous variation of electricity according to household. Determined as follows:

  • During the observation period, if there is more than half of the day electricity is below a given threshold value E, the housing is "vacant";

  • When the observation period exceeds a given threshold value D days, and on a condition satisfied, the housing is "empty."

Now given a residential area of ​​household electricity consumption data, you statistics "vacant" ratios and "vacancy" rate, housing that is more than two states as a percentage of total units of residential housing.

Input formats:

Input of the first row is given a positive integer N (≤1000), total units of residential housing; positive real number to e, the low battery threshold; positive integer D, the observation period threshold. Then N rows, each housing a given power consumption data in the following format:

K E​1​​ E​2​​ ... E​K​​

Where K is the number of days of observation, E i is the i-day consumption.

Output formats:

The percentage ratio of the output values ​​in a row "vacant" and "empty" ratio, with a space therebetween, a retained after the decimal point.

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 explained: the second and third family is "vacant", the first four as "vacant", other users are not empty.)

Analysis: statistics "vacant" and "empty" the number, the conversion ratio percentile can, pay attention, first determine when the vacant vacant judge again, determined to be vacant, then it is not vacant, the vacancy may be in subtracting a

program:

a = input().split()
m = 0
n = 0
for i in range(int(a[0])):
    b = input().split()
    x = 0
    for j in range(1,len(b)):
        if float(b[j])<float(a[1]):
            x+=1
    if x>int(b[0])//2:
        m+=1
        if int(b[0])>int(a[2]):
            n+=1
            m-=1
m = m/int(a[0])*100
n = n/int(a[0])*100
m = '%.1f'%m
n = '%.1f'%n
print("%s%c%c%s%c"%(m,'%',' ',n,'%'),end="")

 

Intelligent Recommendation

[PAT] 1053 Housing Vacancy Rate

1053 Housing vacancy rate (20) (20 points) On the premise of not disturbing the residents, one way to count the vacancy rate of houses is to make judgments based on the continuous change of electricit...

PAT 1053 Housing Vacancy Rate

1053 Housing vacancy rate Without disturbing the residents, one way to count the vacancy rate of houses is to make judgments based on the continuous changes in the electricity consumption per househol...

PAT.1053. Housing vacancy rate

topic time limit 400 ms Memory limit 65536 kB Code length limit 8000 B Judgment procedure Standard Author CHEN, Yue On the premise of not disturbing residents, one way to count the vacancy rate of hou...

Relocations

Relocations By copying the code in the assembly code in start.S Nor Flash to SDRAM, because there is no difference ble attention arm assembler and bne, leading to his own confused for a long time, sta...

IO model

Basic concepts of IO The read system call does not directly read data from the physical device into the memory; the write system call does not directly write data to the physical device. Whether the u...

More Recommendation

Git clone and download zip are different

Today build xv6 + qemu environment, At https://github.com/mit-pdos/xv6-public click download zip to download the compressed package and unzip Then make keeps reporting errors: recipe for target XXX fa...

selenium + python using xpath element positioning error

Scripted pythonIDE >>> from elenium import webdriver >>> from selenium import webdriver >>> b=webdriver.Firefox()   >>>  b.get(r'C:\Users\PC\Desktop\ss\te...

Install KafKa and common commands

      createtopic:./kafka-topics.sh --create --topic JsonData --partitions 3 --replication-factor 1 --zookeeper linux04 delete:bin/kafka-topics.sh --delete --zookeeper sentos01:2181 --t...

ROS Getting Started with ROS

ROS Getting Started with ROS Foreword Skill Knowledge ROS installation Version introduction installation note Foreword Skill Now the ROS system also supports running on Windows, but the adaptation is ...

IDEA needs to reconfigure the maven home solution every time it opens a new maven project

1. Select the file> other settings> settings for new projets option 2. Select build, execution, deployment> build tools> maven options, configure maven home and settings file...

Copyright  DMCA © 2018-2026 - All Rights Reserved - www.programmersought.com  User Notice

Top