Python Project Euler 013:100个50位数和

Problem 13

Work out the first ten digits of the sum of the following one-hundred 50-digit numbers.

...(100个50位数)...

 

为了避免有后面低位进位的情况,取了每个50位数的前13位来运算。

1 def pe013BF():
2     data = open('013.txt', "r")
3     sum1 = str(sum([int(line[:13]) for line in data]))[:10]
4     return sum1
5 
6 if __name__ == '__main__':
7     result = pe013BF()
8     print(result)

 

 

posted @ 2012-12-08 10:52  river_run  阅读(268)  评论(0编辑  收藏  举报