啊……今天高產咩?
好吧~這道題依舊比較簡單,只是要求輸入是算出來的9XXXXXX,不是那個9327...
嗯……這不是重點,重點在於,這道題可以用數學方法手算~
anyway~
上代碼,很簡單的~
def main():
max = 0
for i in range(193, 100000):
num_set = list(str(i)+str(i*2))
if '0' in num_set:
continue
if (len(num_set) == 9) and (len(set(num_set)) == 9):
#make sure there are 9 digits in the list;
#also, make sure there are 9 different digis.
max = i
print(max)
if __name__ == '__main__':
main()
我發現即便python是interpreted,我還是喜歡修改之後編譯一遍……額……以前pascal 用多了……提交答案前compile一次……哈哈~