Created
September 8, 2014 12:41
-
-
Save prehistoricpenguin/33f8d02e471fcb53e701 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://pat.zju.edu.cn/contests/pat-a-practise/1002 | |
import sys | |
import math | |
buf = [0.0] * 1001 | |
def read_line(): | |
line = sys.stdin.readline().split() | |
index = 1 | |
length = len(line) | |
while index < length: | |
exp = int(line[index]) | |
coe = float(line[index + 1]) | |
buf[exp] += coe | |
index += 2 | |
def main(): | |
read_line() | |
read_line() | |
cnt = 0 | |
index = 1000 | |
ans = [] | |
while index >= 0: | |
if math.fabs(buf[index]) > 1e-6: | |
ans.append([index, buf[index]]) | |
cnt += 1 | |
index -= 1 | |
pass | |
if cnt: | |
print cnt, | |
for item in ans: | |
s = "%d %.1f" % (item[0], item[1]) | |
print s, | |
else: | |
print cnt | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment