1 class Solution(object):
2     def smallestRepunitDivByK(self, K: int) -> int:
3         if K % 2 == 0 or K % 5 == 0: 
4             return -1
5         r = 0
6         for N in range(1, K + 1):
7             r = (r * 10 + 1) % K
8             if r == 0: 
9                 return N

 

posted on 2019-03-24 19:14  Sempron2800+  阅读(168)  评论(0编辑  收藏  举报