12.Playing with Calculator
http://acm.fzu.edu.cn/problem.php?pid=1017
import sys
for each in sys.stdin:
# 因为按‘=’键的次数可为0,因此存在N即为k本身的情况,当k为个位数或者k本身各位都为同一个数字,可视为平凡情况来快速给出结论
k=int(each.rstrip())
num_list=[int(x) for x in list(each.rstrip())]
if k<10:
print('%d %d'(k,1))
continue
elif len(num_list)*num_list[0]==sum(num_list):
print('%d %d'%(num_list[0],len(num_list)))
else:
flag=False
for i in range(1,10):
s=0
for j in range(1,k+1):
s=(s*10+i)
if s%k==0:
num=i
length=j
flag=True
break
if flag:
break
if flag:
print('%d %d'%(num,length))
else:
print('-1')