leetcode1022

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

猜你喜欢

转载自www.cnblogs.com/asenyang/p/10589595.html