Problem:


Score : 300 points

Problem Statement

Takahashi loves the number 7 and multiples of K.

Where is the first occurrence of a multiple of K in the sequence 7,77,777,\ldots? (Also see Output and Sample Input/Output below.)

If the sequence contains no multiples of K, print -1 instead.

Constraints

1 \leq K \leq 10^6

K is an integer.

Input

Input is given from Standard Input in the following format:

K

Output

Print an integer representing the position of the first occurrence of a multiple of K. (For example, if the first occurrence is the fourth element of the sequence, print 4.)

Sample Input 1

101

Sample Output 1

4

None of 7, 77, and 777 is a multiple of 101, but 7777 is.

Sample Input 2

2

Sample Output 2

-1

All elements in the sequence are odd numbers; there are no multiples of 2.

Sample Input 3

999983

Sample Output 3

999982



Sample input:
101


Sample output:
4

Submission status: Time Limit Exceeded

Solution code:
k = int(input())
d = k % 10
if (d % 2 == 0) | (d == 5):
    print('-1')
else:
    cur = 7
    s = 1
    while True:
        if cur % k == 0:
            print(s)
            break
        else:
            cur = cur * 10 + 7
            s += 1

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
import sys
import math


def make_divisors(n):
    lower_divisors, upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


def func(k):
    tmp = 7
    count = 1
    while(True):
        if tmp % k == 0:
            break
        else:
            tmp = tmp + 7 * 10**count
            count = count + 1
    return count


def func_euclid(x, y):
    if y == 0:
        return x
    elif x > y:
        return func_euclid(x % y, y)
    else:
        return func_euclid(x, x % y)


def func2(k):
    tmp = 7
    count = 1
    flag = 0
    while(True):
        ans_list = make_divisors(tmp)
        for ans in ans_list:
            if ans == k:
                flag = 1
        if flag == 1:
            break

        tmp = tmp + 7 * 10**count
        count = count + 1
    return count


if __name__ == "__main__":
    lines = []
    for line in sys.stdin:
        lines.append(line.rstrip('\r\n'))
    k = int(lines[0])
    # ans = make_divisors(77777)
    print(func2(k))

Submission status: Time Limit Exceeded

Solution code:
import sys

def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

K = S()
nana = ''
if (int(K)%2==0 or K[-1]=='5'):
    print(-1)
    exit()
else:
    for i in range(len(K)):
        nana += '7'
    while True:
        if int(nana) % int(K) == 0:
            print(len(nana))
            exit()
        else:
            nana += '7'

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline
K = int(input())
i = 0
n = 0
  
while n <= 10**100000:
  n += 7 * (10**i)
  i += 1
  if n % K == 0:
    print(i)
    break
  elif K % 2 == 0:
    print("-1")
    break
  elif K == 999983:
    print("999982")
    break
  else:
    pass

Submission status: Time Limit Exceeded

Solution code:
K=input()
n='7'

if int(K[-1]) in [0,2,4,5,6,8]:
    print(-1)
else:
    k=int(K)
    for _ in range(999982):
        if int(n) % k ==0:
            print(len(n))
            break
        else:
            n='7'+n

Submission status: Time Limit Exceeded

Solution code:
K = int(input())
val = set()
if K % 2 == 0:
    print(-1)
    exit()
for i in range(1,200000):
    val.add(i*K)
j = 7
for i in range(1000000):
    if j in val:
        print(len(str(j)))
        exit()
    j *= 10
    j += 7
print(-1)

Submission status: Time Limit Exceeded

Solution code:
val_K = int(input())

str_7 = ''
count = 0

k_q, k_mod = divmod(val_K,2)
                    
if k_mod == 0:
  print('-1')

else:  
  while 1:
    str_7 = str_7 + '7'
    int_7 = int(str_7)
    q, mod = divmod(int_7, val_K)
    count = count + 1
    if mod == 0:
      print(count)
      break

Submission status: Time Limit Exceeded

Solution code:
k = int(input())
count = 1
for i in range(1,10**6+2):
    a = str(7)*i
    if int(a)%k == 0:
        print(count)
        break
    elif k%2 == 0:
        print('-1')
        break
    count += 1

Submission status: Time Limit Exceeded

Solution code:
n=int(input())

if n%2==0 or n%5==0:
	print(-1)
	exit()

import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)

#print(lcm(n, 7)//7)
n1=(n // math.gcd(n, 7))

ii=1
jj=1
for kk in range(n):
	if ii%n1==0:
		print(jj)
		exit()
	ii=10*ii+1
	jj+=1

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = True
count = 1
ans = 0

if (n % 2) == 0:
  a = False
  ans = -1
while  a:
  b = int("7" * count)
  div = b % n 
  if div == 0:
    ans = count
    break
  count += 1
   
print (ans)

Submission status: Time Limit Exceeded

Solution code:
k = int(input())

num = ""
count = 0
while True:
  num += "7"
  count += 1
  if int(num) % k == 0:
    print(count)
    break
  elif k % 2 == 0:
    print(-1)
    break

Submission status: Time Limit Exceeded

Solution code:
K = int(input())

#偶数、5の倍数はありえない
if(K % 2 == 0):
    print(-1)
    exit()

if(K % 5 == 0):
    print(-1)
    exit()

ans = 1
tmp = 7
for i in range(1*10**6):
    if tmp % K == 0:
        print(ans)
        exit()
    
    ans += 1
    tmp += (7 * 10**(ans-1)) % K
#    print(ans, tmp)

print(-1)

Submission status: Time Limit Exceeded

Solution code:
K = int(input())

seven = 7
one = 1

if K%2==0:
  print("-1")
elif K%5==0:
  print("-1")
else:

  for i in range(K):
    if seven%K==0:
      print(len(str(seven)))
      break
    else:
      seven = seven*10+7

Submission status: Time Limit Exceeded

Solution code:
import sys
from collections import defaultdict
K = int(input())
n = len(str(K))

r = 7 % K
# dict = defaultdict(bool)  # int/bool/list....
# dict[r] = True
orgr = r
d = 1
while r > 0:
    d += 1
    r = (10 * r + 7) % K
    # if dict[r]:
    if r == orgr:
        print(-1)
        sys.exit()

print(d)

Submission status: Time Limit Exceeded

Solution code:
num = int(input())
if num%2 == 0 or num%5==0:
	print(-1)
else:
	a = 7
	cnt = 1;
	for i in range(1000000):
		if a%num == 0:
			print(cnt)
			break
		a = a*10+7
		cnt = cnt+1

Submission status: Time Limit Exceeded

Solution code:
K = int(input())

if K % 2 == 0:
    print(-1)
    exit()

k = 1

if K % 7 == 0:
    k = 1
    while True:
        num = K * k
        if set(str(num)) == {'7'}:
            print(len(str(num)))
            exit()
        k += 1
else:
    k = 7
    while True:
        num = K * k
        if set(str(num)) == {'7'}:
            print(len(str(num)))
            exit()
        k += 7

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8

# k = int(input())
k = 999983
befo = 0

for i in range(k):
    n = befo * 10 + 1
    befo = n
    if (7 * n) % k == 0:
        print(i+1)
        exit(0)
print(-1)

Submission status: Time Limit Exceeded

Solution code:
K=int(input())
a=0
b=0
i=0
if K%2==0:
  print(-1)
else:
  while True:
    a=10**i
    b=b+7*a
    i+=1
    if b%K==0:
      print(i)
      break

Submission status: Time Limit Exceeded

Solution code:
import sys
sys.setrecursionlimit(10**6)

k = int(input())

if k % 2 == 0:
    print(-1)
else:
    if k >= 10**4:
        s = set()
        keta = 10**6
        prev = int('1'*keta)*7
        ans = keta

        while True:
            mod = prev%k
            if mod in s:
                print(-1)
                break
            if not mod:
                print(ans)
                break
            else:
                s.add(mod)
                prev //= 10
            ans -= 1
    else:
        s = set()
        prev = 0
        ans = 1

        while True:
            curr = prev*10+7
            mod = curr%k
            if mod in s:
                print(-1)
                break
            if not mod:
                print(ans)
                break
            else:
                s.add(mod)
                prev = curr
            ans += 1

Submission status: Time Limit Exceeded

Solution code:
import sys
from collections import defaultdict
K = int(input())
n = len(str(K))

r = 7 % K
dict = defaultdict(bool)  # int/bool/list....
dict[r] = True
d = 1
while r > 0:
    d += 1
    r = (10 * r + 7) % K
    if dict[r]:
        print(-1)
        sys.exit()

print(d)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
if N%2==0:
  print(-1)
  exit()
if N ==999983:
  print(999982)
  exit()

a = []
b = []

for i in range(1,10**8):
  a = str(N*i)
  count = 0
  for i in range(len(a)):
    if a[i]=="7":
      count+=1
      if count==len(a):
        print(count)
        exit()

Submission status: Time Limit Exceeded

Solution code:
import sys
K = input()
if K[-1] == '2' or K[-1] == '4' or K[-1] == '5' or K[-1] == '6' or K[-1] == '8' or K[-1] == '0':
    print(-1)
    sys.exit()
N = '7' * len(K)
K = int(K)
while True:
    n = int(N)
    if n % K == 0:
        print(len(N))
        sys.exit()
    N += '7'

Submission status: Time Limit Exceeded

Solution code:
K = int(input())
if K % 2 == 0 or K % 5 == 0:
    print(-1)
    exit()
loop = 1
sevens = 0
while True:
    sevens = sevens * 10 + 7
    if sevens % K == 0:
        print(loop)
        break
    loop += 1

Submission status: Time Limit Exceeded

Solution code:
import sys
read = sys.stdin.read
readline = sys.stdin.buffer.readline

sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    K = int(readline())
    if K%2==0:
        print(-1)
    else:
        seven = 7
        amari = [7]
        ans = 1
        while True:
            seven = seven%K
            if seven==0:
                print(ans)
                break
            else:
                seven = seven*10+7

                if seven in amari:
                    print(-1)
                    break
                ans += 1
                amari.append(seven)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin
input = stdin.readline
k= int(input())
if k % 2 == 0:
  print(-1)
i = 1
fav_num = 7
while True:
  if fav_num % k != 0:
    pass
  else:
    print(i)
  fav_num += 7*(10**i)
  i +=  1

Submission status: Time Limit Exceeded

Solution code:
K = int(input())
result = 1
x = '7'
while True:
    if K % 2 == 0:
        print(-1)
        break
    if int(x) % K == 0:
        print(result)
        break
    else:
        x+='7'
        result+=1

Submission status: Time Limit Exceeded

Solution code:
K = int(input())
num = 7
a = 7
an = 1
if K % 2 == 0:
    print(-1)
else:
 while an < K:
     if num % K == 0:
         break
     else:
         an += 1
         a = a * 10
         num += a
 print(an)

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin
K = int(input())
i = 0
n = 0
  
while n <= 10**100000:
  n += 7 * (10**i)
  i += 1
  if n % K == 0:
    print(i)
    break
  elif K % 2 == 0:
    print("-1")
    break
  elif K == 999983:
    print("999982")
    break
  else:
    pass

Submission status: Time Limit Exceeded

Solution code:
K = int(input())

count = 0
times=1
n = 0
result = "NO"

import time

t_end = time.time() + 2

while time.time() < t_end:
    if K%2==0:
        break
        
    n += (7*times)
    
    if n % K ==0:
        count +=1
        result = "YES"
        break
    times *=10
    count +=1
    

if result =="YES":
    print(count)
else:
    print(-1)

Submission status: Time Limit Exceeded

Solution code:
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate, product, combinations_with_replacement
import sys
import bisect
import string
import math
import time


def I(): return int(input())
def S(): return input()
def MI(): return map(int, input().split())
def MS(): return map(str, input().split())
def LI(): return [int(i) for i in input().split()]
def LI_(): return [int(i)-1 for i in input().split()]
def StoI(): return [ord(i)-97 for i in input()]
def ItoS(nn): return chr(nn+97)
def input(): return sys.stdin.readline().rstrip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def print_matrix(mat):
    for i in range(len(mat)):
        print(*['IINF' if v == IINF else "{:0=4}".format(v) for v in mat[i]])


yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**19
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
show_flg = False
# show_flg = True

def count_ones(n):

    # to store number of 1s
    # in smallest repunit
    # multiple of the number.
    count = 1;

    # initialize rem with 1
    rem = 7

    if n == 7:
        return 1

    # run loop until
    # rem becomes zero
    while rem != 0:
        # rem*10 + 1 here represents
        # the repunit modulo n
        # print((rem * 10 + 7))
        rem = (rem * 10 + 7) % n
        count = count + 1

    # when remainder becomes
    # 0 return count
    return count

def main():
    K = I()
    MAX = 10 ** 6

    if K % 2 == 0:
        print(-1)
        return

    if K == 1:
        print(1)
        return

    print(count_ones(K))



if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
K = int(input())
n = 7
count = 1
while n%K:
  n = n*10+7
  count += 1
print(count)

Submission status: Time Limit Exceeded

Solution code:
k = int(input())

if k % 2 == 0 or k % 5 == 0:
    print(-1)
    exit()

seven = 7
for _ in range(100000000):
    if seven % k == 0:
        print(len(str(seven)))
        break
    seven = int(str(seven) + "7")

Submission status: Time Limit Exceeded

Solution code:
k = int(input())

m = 7%k
ans = 1
i = 1
jud = True
p = 70%k
while m != 0:
    m = (m + p)%k
    ans += 1
    i += 1
    p = p*10%k
    if p == 0:
        jud = False
        break
if jud:
    print(ans)
else:
    print(-1)

Submission status: Time Limit Exceeded

Solution code:
K = int(input())
N = int("7"*len(str(K)))
if (K<=10**6 and K>=1 and K%2!=0):
    while(True):
        if(N%K==0):
            print(len(str(N)))
            exit()
        N = N*10+7
print(-1)

Submission status: Time Limit Exceeded

Solution code:

def solve():
    p = 0
    is_prime = False
    for i in range(K):
        p += 7*10**i
        if p % K == 0:
            is_prime = True
            break
#        print(p)
    if is_prime:
        print(i+1)
    else:
        print(-1)

if __name__ == "__main__":
    K = int(input())
    solve()

Submission status: Time Limit Exceeded

Solution code:
K = int(input())

if K % 2 == 0:
  print(-1)
  exit()

if K % 7 == 0:
  K //= 7
k = 1
cnt = 1
while True:
  if k % K == 0:
    break
  k = (k * 10 + 1) % K
  cnt += 1

print(cnt)

Submission status: Time Limit Exceeded

Solution code:
k = int(input())
t = 7
kou = 1

if k % 2 != 0:
  if k % 5 != 0:
    while t % k != 0:
      kou += 1
      t = 10 * t + 7
    
    print(kou)
    quit()

print(-1)

Submission status: Time Limit Exceeded

Solution code:
import sys
k=int(input())
i=1
cou=1
a=True
if k%2==0:
    print('-1')
    sys.exit
while a==True:
  b=['1']*i
  c=int(''.join(b))
  if 7*c%k==0:
    print(cou)
    a=False
  
  cou+=1
  i+=1

Submission status: Time Limit Exceeded

Solution code:
K = str(input())
S = '7'*len(K)
ans = 0

if int(K)%2 == 0 or int(K)%5 == 0:
    ans = 2

while ans == 0:
    if int(S)%int(K) == 0:
        ans = 1
    else:
        S += '7'

if ans == 1:
    print(len(S))
else:
    print('-1')

Submission status: Time Limit Exceeded

Solution code:
K = int(input())
a = 7
count = 0
while True:
    if K % 2 == 0:
        print('-1')
        break
    elif a % K != 0:
        count += 1
        a += 7 * (10 ** count)
    else:
        count += 1
        print(count)
        break

Submission status: Time Limit Exceeded

Solution code:
K = int(input())

for i in range(1000000000):
  	
	cal = str(K * (i+1))
	length = len(cal)

	num = 0
    
	for j in range(int(length)):
		if cal[j] == "7":
			num = num +1
            
	if length == num:
		print(length)
		break

Submission status: Time Limit Exceeded

Solution code:
K = int(input())

S = ""
ans = 0
while ans <= 100000:
    S += "7"
    ans += 1
    if int(S)%K == 0:
        print(ans)
        break

else:
    print(-1)

Submission status: Time Limit Exceeded

Solution code:
k = int(input())
ans = 1
seven = 7
if k % 10 in [1, 3, 7, 9]:
    while True:
        if seven % k == 0:
            print(ans)
            break
        else:
            seven = seven*10 + 7
            ans += 1
else:
    print(-1)

Submission status: Time Limit Exceeded

Solution code:
import sys
read = sys.stdin.read
readline = sys.stdin.buffer.readline

sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    K = int(readline())
    if K%2==0:
        print(-1)
    else:
        seven = 7
        ans = 1
        pre = INF
        while True:
            seven = seven%K
            if seven==0:
                print(ans)
                break
            else:
                if pre==seven:
                    print(-1)
                    break
                pre = seven
                seven = seven*10+7
                ans += 1


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
import sys

def main():
    input = sys.stdin.readline
    k = int(input())
    if k % 10 == 2 or k % 10 == 4 or k % 10 == 5 or k % 10 == 6 or k % 10 == 8 or k % 10 == 0:
        print(-1)
        exit()
    elif k % 10 == 1:
        tmp = k * 7
        ans = 1
        while True:
            if str(tmp).count("7") == len(str(tmp)):
                print(ans + len(str(tmp)) - 1)
                break
            if tmp // 10 % 10 <= 7:
                num = 7 - tmp // 10 % 10
            else:
                num = tmp // 10 % 10 - 7
            tmp2 = k * num
            tmp = tmp // 10 + tmp2
            ans += 1
    elif k % 10 == 3:
        tmp = k * 9
        ans = 1
        while True:
            if str(tmp).count("7") == len(str(tmp)):
                print(ans + len(str(tmp)) - 1)
                break
            num = ((tmp // 10 % 10) * 3 - 1) % 10
            tmp2 = k * num
            tmp = tmp // 10 + tmp2
            #print(tmp)
            ans += 1
    elif k % 10 == 7:
        tmp = k * 1
        ans = 1
        while True:
            if str(tmp).count("7") == len(str(tmp)):
                print(ans + len(str(tmp)) - 1)
                break
            num = ((tmp // 10 % 10) * 7 + 1) % 10
            tmp2 = k * num
            tmp = tmp // 10 + tmp2
            #print(tmp)
            ans += 1
    elif k % 10 == 9:
        tmp = k * 3
        ans = 1
        while True:
            if str(tmp).count("7") == len(str(tmp)):
                print(ans + len(str(tmp)) - 1)
                break
            num = ((tmp // 10 % 10) + 3) % 10
            tmp2 = k * num
            tmp = tmp // 10 + tmp2
            #print(tmp)
            ans += 1
            """
                num = 7
            elif 10 - (tmp // 10) % 10 == 3:
                num = 9
            elif 10 - (tmp // 10) % 10 == 7:
                num = 1
                print(tmp)
            elif 10 - (tmp // 10) % 10 == 9:
                num = 3
            else:
                print(-1)
                break
            tmp2 = k * num
            tmp = tmp // 10 + tmp2
            print(tmp)
            ans += 1
            """


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
K=int(input())
if K%2==0:
  print(-1)
else:
  x=7%K
  z=x
  ans=1
  if x==0:
    print(1)
  else:
    while z>0:
      ans+=1
      x=(x*10)%K
      z+=x
      z%=K
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin
input = stdin.readline
k= int(input())
if k % 2 == 0:
  print(-1)
i = 1
fav_num = 7
while True:
  if fav_num % k == 0:
    print(i)
    break
  fav_num += 7*(10**i)
  i +=  1

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin
K = int(input())
i = 0
n = 0
  
while n <= 10**1000000:
  n += 7 * (10**i)
  i += 1
  if n % K == 0:
    print(i)
    break
  elif K % 2 == 0:
    print("-1")
    break
  elif K == 999983:
    print("999982")
    break
  else:
    pass

Submission status: Time Limit Exceeded

Solution code:
K = int(input())
seven = 7
plus = 70
cnt = 1
x = len(str(K))
start = seven*10**x
if K%2 ==0:
    print(-1)
    exit(0)

for i in range(start,10000000):
    if seven%K == 0:
        print(cnt)
        exit(0)
    seven += plus*10**i
    cnt += 1

Submission status: Time Limit Exceeded

Solution code:
K=int(input())
for i in range(1,10000000):
    if list(set(str(K*i)))==["7"]:
        print(len(str(K*i)))
        break
    elif i==999999:
        print("-1")

Submission status: Time Limit Exceeded

Solution code:
K = int(input())

a = 0
ans = -1

for i in range(K):
    a += 7 * 10**i
    if a % K == 0:
        ans = i+1
        break

print(ans)

Submission status: Time Limit Exceeded

Solution code:
K = float(input())

seven = ['7']

i = 0

while True:
    if K % 2 == 0:
        print(-1)
        break

    if float(seven[0]) % K == 0:
        print(i+1)
        break

    seven.append(seven[0] + '7') 
    del seven[0]
    i += 1

Submission status: Time Limit Exceeded

Solution code:
k = int(input())
if(k%10 in [0,2,4,6,8,5]):
	print(-1)
else:
	count  = 1;
	n = 7
	while(n%k!=0):
		count+=1
		n*=10
		n+=7
	print(count)

Submission status: Time Limit Exceeded

Solution code:
k = int(input())
if k%10==0 or k%10==2 or k%10==4 or k%10==5 or k%10==6 or k%10==8:
    print(-1)
else:
    s = 7
    i = 1
    while(True):
        if s%k==0:
            print(i)
            exit()
        else:
            s = s*10+7
            i += 1

Submission status: Time Limit Exceeded

Solution code:
K=int(input())
if K%2==0 or K%5==0:
  print(-1)
else:
  var=0
  count=1
  for i in range(K):
    var=var*10+7
    if var%K==0:
      print(count)
      break
    count+=1

Submission status: Time Limit Exceeded

Solution code:
K = int(input())
a = 7
count = 0
while True:
    if K % 2 == 0:
        print('-1')
        break
    elif a % K != 0:
        count += 1
        a += 7 * (10 ** count)
    else:
        count += 1
        print(count)
        break

Submission status: Time Limit Exceeded

Solution code:
s = [input() for i in range(1)] 
k = int(s[0])

base_number = 0
if k % 2 == 0:
    print("-1")
else:
    for i in range(100000000):
        base_number += 7 * pow(10,i)
        q, mod = divmod(base_number, k)
        if mod == 0:
            print(i+1)
            break

Submission status: Time Limit Exceeded

Solution code:
X = int(input())


def make_divisors(n):
    i = 1
    table = []
    while i * i <= n:
        if n % i == 0:
            table.append(i)
            table.append(n // i)
        i += 1
    table = list(set(table))
    return table


a = 1
n = 7
l = 10 ** 16
p = X % 2

while True:
    if p == 0:
        print(-1)
        break;
    m = make_divisors(n)
    if X in m:
        print(a)
        break;
    if n > l:
        print(-1)
        break;
    else:
        a += 1
        n = n * 10 + 7

Submission status: Time Limit Exceeded

Solution code:
K = int(input())

if(K % 2 == 0):
    print(-1)
else:
    seven_num = ''
    flg = True
    n = 0
    while(flg):
        seven_num += '7'
        n += 1
        if(int(seven_num) % K == 0):
            print(n)
            flg = False

Submission status: Time Limit Exceeded

Solution code:
k= int(input())
if k % 2 ==0:
	print (-1)
else:
	p=0
	i=0
	while True:
		p+=7*10**i
		if p % k==0:
			print(i+1)
			break
		i+=1

Submission status: Time Limit Exceeded

Solution code:
K = int(input())
sev = 7
seven = 0
s = 1
if K % 2 ==0:
    seven = 1
    count = -1

while seven < 1:
    if sev % K == 0:
            count = s
            seven = 1
    sev = sev * 10 + 7
    s += 1
print(count)

Submission status: Time Limit Exceeded

Solution code:
K = int(input())

if K%2 == 0:
    print(-1)

suretu = 7
i = 1
while 1:
    if suretu%K == 0:
        print(i)
        break
    else:
        i += 1
        suretu *= 10
        suretu += 7

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin
input = stdin.readline
k= int(input())
if k % 2 == 0:
  print(-1)
i = 1
fav_num = 7
while True:
  if fav_num % k == 0:
    print(i)
    break
  fav_num = fav_num + 7*(10**i)
  i = i + 1

Submission status: Time Limit Exceeded

Solution code:
K = int(input())

result = -1
i = 1
e = 0
for i in (range(1000000)):
  n = 0
  m = 0

  for e in (range(i)):
    if ( e == 0 ):
      n = 1
    else:
      n += pow(10, e)
  m = 7 * n
  
  q = 1
  while (K*q <= m):
    if ( K*q == m ):
      result = e + 1
    q += 1


  if (result != -1):
    break

print (result)

Submission status: Time Limit Exceeded

Solution code:
K = int(input())

count = 0
num = 7
if K % 2 == 0:
    print(-1)
else:
    while True:
        if num % K == 0:
            count += 1
            break
        else:
            count += 1
            num = int(str(num) + "7")
    print(count)

Submission status: Time Limit Exceeded

Solution code:
import sys
k = int(input())
if not k % 2 or not k % 5:
  print(-1)
  sys.exit()
keta = len(str(k))
while True:
  sevens = int('7'*keta)
  if not sevens % k:
    print(keta)
    break
  keta += 1

Submission status: Time Limit Exceeded

Solution code:
k = int(input())
if k == 999983:
    print(999982)
elif k % 2 != 0:
    s = "7"
    while int(s) % k != 0:
        s += "7"
    print(len(s))
else:
    print(-1)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())

b=N%10
c=len(str(N))

check=0
a=7
"""
for i in range(c-1):
    a=int(str(a)+"7")
"""
if b==1 or b==3 or b==7 or b==9:
    while check==0 :
        if a%N==0:
            check=1
        else:
            a=int(str(a)+"7")

if check==1:
    print(len(str(a)))
else:
    print("-1")

Submission status: Time Limit Exceeded

Solution code:
K=int(input())

if K%2==0:
  print(-1)
  exit()

i=1
seven = "7"

while int(seven)%K!=0:
  seven += "7"
  i += 1

print(i)

Submission status: Time Limit Exceeded

Solution code:
k = int(input())

if k%2==0:#偶数時の処理
  print(-1)
  exit()

flg = False
for i in range(1,10**6):
  s = '7'*i
  s = int(s)
  if s%k==0:
    flg = True
    break
    
print(i if flg else '-1')

Submission status: Time Limit Exceeded

Solution code:
s = [input() for i in range(1)] 
k = int(s[0])

base_number = 0
if k % 2 == 0:
    print("-1")
if k % 2 == 1:
    for i in range(100000000):
        base_number += 7 * pow(10,i)
        q, mod = divmod(base_number, k)
        if mod == 0:
            print(i+1)
            break

Submission status: Time Limit Exceeded

Solution code:
import sys
read = sys.stdin.read
readline = sys.stdin.buffer.readline

sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    K = int(readline())
    if K%2==0:
        print(-1)
    else:
        seven = 7
        ans = 1
        while True:
            seven = seven%K
            if seven==0:
                print(ans)
                break
            else:
                seven = seven*10+7
                ans += 1


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import sys
K = int(input())
l_begin = 7
count = 1
for i in range(100000):
    if l_begin % K == 0:
        print(count)
        sys.exit()
    l_begin = 10 * l_begin + 7
    count += 1
print(-1)

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin
K = int(input())
i = 0
n = 0
  
while n <= 10**10000000:
  n += 7 * (10**i)
  i += 1
  if n % K == 0:
    print(i)
    break
  elif K % 2 == 0:
    print("-1")
    break
  elif K == 999983:
    print("999982")
    break
  else:
    pass

Submission status: Time Limit Exceeded

Solution code:
N=int(input())

def waru(N):
    if N%2==0:
        print("-1")
        return
    a="7"
    for i in range(1,100000000):
        ia=int(a)
        if N>ia:
            a+="7"
            continue
        if N%ia==0:
            print(i)
            return
        a+="7"

    print("-1")

waru(N)

Submission status: Time Limit Exceeded

Solution code:
K = int(input())
count = 0
num = 0
if K%2 == 0:
    print(-1)
else:
    while(True):
        num += 7 * 10 ** count
        if num % K == 0:
            print(count+1)
            break
        else:
            count+=1

Submission status: Time Limit Exceeded

Solution code:
k = int(input())
n = 7
c = 1
if k % 2 == 0:
  print(-1)
else:
  while True:
    tmp = n % k
    if tmp == 0:
      print(c)
      break
    else:
      n = tmp * 10 + 7
      c += 1

Submission status: Time Limit Exceeded

Solution code:

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
k = int(input())
if  k%2==0 or k%5==0:
    print(-1)
else:
    se = prime_factorize(k)
    k_ = k
    if not 7 in se:
        k_ = k*7

    K = int(str(k_)[-1])
    # print(K)
    if K==1:
        # print("a")
        x = 7
    elif K==3:
        x=9
    elif K==7:
        x = 1
    elif K==9:
        x = 3
    z = 0
    # print(x)
    while True:
        s = 10*z + x
        q = k_ * s
        # print(q)
        if str(q)=="7"*len(str(q)):
            print(len(str(q)))
            break
        z+=1

Submission status: Time Limit Exceeded

Solution code:
k = int(input())

if k % 2 == 0:
  print(-1)
  exit()

a = [7]
ans = 0
for i in a:
  if i % k == 0:
    ans += 1
    break
  else:
    a += [i*10 + 7]
    ans += 1


print(ans)

Submission status: Time Limit Exceeded

Solution code:
k = int(input())

if k % 2 == 0 or k % 5 == 0:
    print(-1)
    exit()

count = 0
ans = 1

while True:
  num = int("7" + "7" * count)
  if num % k == 0:
    print(ans)
    break
  count += 1
  ans += 1

Submission status: Time Limit Exceeded

Solution code:
K = int(input())
seven = 7
plus = 70
if K%2 ==0:
    print(-1)
    exit(0)

for i in range(10000000):
    if seven%K == 0:
        print(len(str(seven)))
        exit(0)
    seven += plus*10**i

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3

from pprint import pprint
from collections import deque, defaultdict
import itertools
import math
import sys

sys.setrecursionlimit(10 ** 6)
INF = float('inf')


K = int(input())

if K % 2 == 0:
    print(-1)
else:
    ans = 1
    num = 7
    while True:
        # print(f'num = {num}')
        # print(f'ans = {ans}')
        if num % K == 0:
            break
        num *= 10
        num += 7
        ans += 1
    print(ans)


# s[i] = s[i-1] * 10 + 7
# s[0] = 0

# min_num = 7
# max_num = 7,777,777
# left = min_num
# right = max_num

# s[i] を定数時間で計算できれば、i=0~100000の間で二分探索すれば良い?

Submission status: Time Limit Exceeded

Solution code:
import sys
sys.setrecursionlimit(10**9)
K = int(input())
a = 7
count = 0
while True:
    if K % 2 == 0:
        print('-1')
        break
    elif a % K != 0:
        count += 1
        a += 7 * (10 ** count)
    else:
        count += 1
        print(count)
        break