首页 > 代码库 > ZOJ1969-Hard to Believe, but True!

ZOJ1969-Hard to Believe, but True!

 1 import re 2 while True: 3     x = raw_input() 4     if(x == 0+0=0): 5         print True 6         break 7     a,b,c = re.split([+=], x) 8     [a,b,c] = [int(‘‘.join(list(x)[::-1])) for x in [a,b,c]] 9     if(a+b == c):10         print True11     else:12         print False 

额,判断一个算式是否符合她的加法规则,

 

比如73+42=16.

 

如果37+24 == 61,,那么就符合了,,这里用到正则分割字符串,,字符串到list然后切片再join到字符串然后转化到int,,不知道有没有更好的写法..

ZOJ1969-Hard to Believe, but True!