Love丶FFC's Blog
给定一系列正整数,请按要求对数字进行分类,并输出以下 5 个数字:
A1 = 能被 5 整除的数字中所有偶数的和;
A2 = 将被 5 除后余 1 的数字按给出顺序进行交错求和,即计算 n1−n2+n3−n4⋯;
A3 = 被 5 除后余 2 的数字的个数;
A4 = 被 5 除后余 3 的数字的平均数,精确到小数点后 1 位;
A5 = 被 5 除后余 4 的数字中最大数字。
每个输入包含 1 个测试用例。每个测试用例先给出一个不超过 1000 的正整数 N,随后给出 N 个不超过 1000 的待分类的正整数。数字间以空格分隔。
对给定的 N 个正整数,按题目要求计算 A1~A5 并在一行中顺序输出。数字间以空格分隔,但行末不得有多余空格。
若其中某一类数字不存在,则在相应位置输出 N
。
13 1 2 3 4 5 6 7 8 9 10 20 16 18
30 11 2 9.7 9
8 1 2 4 5 6 7 9 16
N 11 2 N 9
1.逐个判断,添加到对应列表
2.对列表长度进行判断,进行后续操作
Number = list(map(int, input().split())) A1 = list() A2 = list() A3 = list() A4 = list() A5 = list() for content in Number[1:]: value = content % 5 if value == 0 and content % 2 == 0: A1.append(content) elif value == 1: A2.append(content) elif value == 2: A3.append(content) elif value == 3: A4.append(content) elif value == 4: A5.append(content) if len(A1) != 0: A1 = sum(A1) else: A1 = 'N' if len(A2) != 0: StaggeredSum = 0 for i in range(len(A2)): StaggeredSum += ((-1) ** i) * A2[i] A2 = StaggeredSum else: A2 = 'N' if len(A3) != 0: A3 = len(A3) else: A3 = 'N' if len(A4) != 0: A4 = round(sum(A4) / len(A4), 1) else: A4 = 'N' if len(A5) != 0: A5 = max(A5) else: A5 = 'N' print(A1, A2, A3, A4, A5)
louis vuitton outlet
I just wanted to thank you for the fast service. while well as they look great. I received them a day earlier than expected. particularly I will definitely continue to buy from this site. anyway I will recommend this site to my friends. Thanks!
louis vuitton outlet https://www.louisvuittonsoutletstore.com/
cheap jordans for sale
I just wanted to thank you for the fast service. or maybe a they look great. I received them a day earlier than expected. similar to the reduction I will definitely continue to buy from this site. either way I will recommend this site to my friends. Thanks!
cheap jordans for sale https://www.cheaprealjordan.com/
cheap jordan shoes
I just wanted to thank you for the fast service. possibly they look great. I received them a day earlier than expected. which includes I will definitely continue to buy from this site. no matter what I will recommend this site to my friends. Thanks!
cheap jordan shoes https://www.realcheapretrojordanshoes.com/
cheap jordans
I just wanted to thank you for the fast service. or even they look great. I received them a day earlier than expected. for instance the I will definitely continue to buy from this site. you decide I will recommend this site to my friends. Thanks!
cheap jordans https://www.realjordansretro.com/
FoorryNox
roman viagra review The rate of mucus plug was 82 41 50 and 6
cheap jordans online
Read reviews and was a little hesitant since I had already inputted my order. actually but thank god, I had no issues. just like received item in a timely matter, they are in new condition. situation so happy I made the purchase. Will be definitely be purchasing again.
cheap jordans online https://www.cheapretrojordan.com/
cheap jordans
Read reviews and was a little hesitant since I had already inputted my order. or possibly a but thank god, I had no issues. which includes received item in a timely matter, they are in new condition. either way so happy I made the purchase. Will be definitely be purchasing again.
cheap jordans https://www.realcheapjordan.com/
cheap louis vuitton
Read reviews and was a little hesitant since I had already inputted my order. or simply but thank god, I had no issues. choose the received item in a timely matter, they are in new condition. regardless so happy I made the purchase. Will be definitely be purchasing again.
cheap louis vuitton https://www.louisvuittonsoutletonline.com/
Preliaf
levitra generico andorra To maximize returns, add a few splurges in the master bath a linen closet, plus a separate shower stall and tub, which 82 of buyers rated as essential or desirable, according to the National Association of Homebuilders