给你一个正整数列表 L, 判断列表内所有数字乘积的最后一个非零数字的奇偶性.如果为奇数输出1,偶数则输出0.. 例如:L=[2,8,3,50] 则输出:0 L = [2,8,3,50] c2 = 0 c5 = 0 for i in L: while i % 2==0: c2+=1 i/=2 while i%5==0: c5+=1 i/=5 if(c2>c5): #因为当2的个数比5的个数多时,就是偶数,否则为奇数 print(0) else: print(1)…
http://hi.baidu.com/nicker2010/item/4fa83c4c5050b3e5a4c066ec 另一个 Last non-zero Digit in N! Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 5695 Accepted Submission(s): 1416 Problem Descripti…
结尾0的个数 描述: 给你一个正整数列表 L, 输出L内所有数字的乘积末尾0的个数.(提示:不要直接相乘,数字很多,相乘得到的结果可能会很大). 例如: L=[2,8,3,50], 则输出:2 n = len(L) x = 1 ans = 0 def calc(x): ret = 0 while True: if x%10==0: ret +=1 x /=10 else: break return [ret,x] for i in range(0,n): x = x*L[i] ret = cal…
题目id: 1 just print a+b give you two var a and b, print the value of a+b, just do it!! print a+b 题目id: 2 list排序 给你一个list L, 如 L=[2,8,3,50], 对L进行升序排序并输出 print sorted(L) 题目id: 3 字符串逆序 给你一个字符串 a, 如a=‘12345’,对a进行逆序输出a. print a[::-1] 题目id:4 输出字典key 给你一…
POJ中有些问题给出了一个长数字序列(即序列中的数字非常多),这个长数字序列的生成有一定的规律,要求求出这个长数字序列中某个位上的数字是多少.这种问题通过分析,找出规律就容易解决. 例如,N!是一个非常大的数,其末尾有很多个0,如何求得其最后一个非零的数字? N!的最后一个非零的数字 [例1]Just the Facts (POJ 1604) Description The expression N!, read as "N factorial," denotes the produc…