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())
if K % 2 == 0:
    print(-1)
    exit()
i = 1
ans = 1
while True:
    if int("7" * i) % K == 0:
        print(ans)
        break
    i += 1
    ans += 1

Submission status: Time Limit Exceeded

Solution code:
k = int(input())
n = '7'
cnt = 1
if k % 2 == 0:
    print(-1)
else:
    while True:
        num = int(n)
        if num%k == 0:
            print(cnt)
            break
        elif cnt == 100000:
            print(k-1)
            break
        else:
            cnt += 1
            n += '7'

Submission status: Time Limit Exceeded

Solution code:
num = int(input())

s = 7
c = 0
a = []


def prime_factorize(n):
    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

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

else:
    while True:
        c += 1
        prime_factorize(s)
        if num in a:
            print(c)
            break
        else:
            s = s * 10 + 7

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:

K = int(input())

cnt = 1
seven = 7


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

else:


  while True:
    if seven%K==0:
      print(cnt)
      break
    else:
      cnt = cnt + 1
      seven = seven*10+7

Submission status: Time Limit Exceeded

Solution code:
K = int(input())
if K % 2 == 0:
    print(-1)
else:
    for i in range(1,1000000):
        if i == 1:
            n = 7
        else:
            n = n + 7*(10**(i-1))
        if n % K == 0:
            print(i)
            break

Submission status: Time Limit Exceeded

Solution code:
k = int(input())
number = 7
cnt = 1
if k % 2 == 0:
    print(-1)
    exit()
while 1:
    if number % k == 0:
        print(cnt)
        break
    else:
        cnt += 1
        number = number + 7 * 10 ** (cnt - 1)

Submission status: Time Limit Exceeded

Solution code:
k = int(input())

number = 1
Seq = 7

while True:

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

    #if Seq > 10**6:
    #    print(-1)
    #    break
    elif Seq % k == 0:
        print(number)
        break
    else:
        Seq = Seq + 7 * (10 ** number)
        number += 1
        #print(Seq)

Submission status: Time Limit Exceeded

Solution code:
K = int(input())

n = 1
x = 7


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

while 1:
  if x % K == 0:
    print( n )
    break
  x = (x % K) * 10 + 7
  n += 1
#

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
 
## Library
 
import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools
import copy
 
## input
 
# N=int(input())
# A,B,C,D=map(int, input().split())
# S = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]
#    S = []
#    for _ in range(N):
#        S.append(list(input()))
 
K=int(input())

if K%2 == 0 or K%5==0:
    print(-1)
    sys.exit()

tmp = "7"

for i in range(10**6):
    if int(tmp)%K == 0:
        print(i+1)
        sys.exit()        
    tmp += "7"

print(-1)

Submission status: Time Limit Exceeded

Solution code:
K = int(input())
t = 0
c = 0 
for i in range(K):
  t = t + 10**i
  s = 7 * t
  if s%K==0:
    print(i + 1)
    c = c + 1
    break
  else:
    pass
if c == 0:
  print(-1)

Submission status: Time Limit Exceeded

Solution code:
K = int(input())

if K % 2 == 0:
    print(-1)
else:
    i = 1
    v = 7
    while True:
        if v % K == 0:
            print(i)
            break
        else:
            i += 1
            v = v * 10 + 7
            v %= K

Submission status: Time Limit Exceeded

Solution code:
K = str(input())
S = '7'*len(K)
ans = 0
while ans == 0:
    if int(S)%int(K) == 0:
        ans = 1
    elif int(K)%2 == 0 or int(K)%5 == 0:
        break
    else:
        S += '7'

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

Submission status: Time Limit Exceeded

Solution code:
K = int(input())

if K % 2 == 0:
  print(-1)
  exit(0)
  
nana = 7
while nana % K != 0:
  nana = nana * 10 + 7
print(len(str(nana)))

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
if(n%2==0):
    print("-1")
else:
    m=1
    while(True):
        s="7"*m
        s1=int(s)
        if s1%n==0:
            print(m)
            break
        m+=1

Submission status: Time Limit Exceeded

Solution code:
K = int(input())
ans = -1

if K % 2 == 0: 
  print(ans)
  exit()
if K == 999983:
  print(999982)
  exit()
for i in range(1, 10**5):
  num = ''.join(['7'] * i)
  if (int(num) % K == 0):
    ans = i
    print(ans)
    exit()
print(ans)

Submission status: Time Limit Exceeded

Solution code:
k = int(input())

s = '7'
count = 1

while True:
    if int(s) % k == 0:
        break
    count += 1
    s += '7'

print(count)

Submission status: Time Limit Exceeded

Solution code:
k = int(input())

s = 0

count = 0

for i in range(1000000):
  s += 7*(10**count)
  count += 1
  if(k==2):
    print(-1)
    break
  if(s % k == 0):
    print(count)
    break

Submission status: Time Limit Exceeded

Solution code:
import math

K = int(input())

cnt = 1
seven = 7


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

else:


  while True:
    if seven%K==0:
      print(cnt)
      break
    else:
      cnt = cnt + 1
      seven = seven*10+7

Submission status: Time Limit Exceeded

Solution code:
a = 7
num = 0
cnt = 1
b=int(input())
while True:
    if b%2 == 0:
        num=-1
        break
    if a%b==0:
        num=cnt
        break
    cnt += 1
    a = a*10+7    
print("{}".format(num))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math


def isPrime(n):
    if n == 2:
        return True
    if n % 2 == 0:
        return False

    m = math.floor(math.sqrt(n)) + 1
    for p in range(3, m, 2):
        if n % p == 0:
            return False
    return True

num = int(input())

listOfNum = len(set(list(str(num))))
primeFlg = isPrime(num)

cnt = 1
sevens = 7

if num % 2 == 0 or num % 5 == 0:
    print(-1)
else:
    if listOfNum > 2 and primeFlg:
        print(num - 1)
    else:
        while sevens % num != 0:
            cnt += 1
            sevens = 7 * int("".join(["1"] * cnt))
        print(cnt)

Submission status: Time Limit Exceeded

Solution code:
k = int(input())
base = 1
i = 1
ans = -1
while i <= 10**6:
    if (7*base) % k == 0:
        ans = i
        break
    base += 10**i
    i += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
k=int(input())
ans=1
mod=7%k
mod1=7%k
if k%2==0:
  print(-1)
  
else:
  
  while mod1!=0:
    mod=(mod*10)%k
    mod1=mod1+mod
    if mod1>=k:
      mod1=mod1%k
    ans+=1
  
  print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline

k = int(input())

n = 1

if k % 2  == 0:
    n = -1
else:
    r = 7 % k
    s = r

    while True:
        if r == 0:
            break
        else:
            r = (r * 10 + s) % k
            n += 1

print(n)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline
K = int(input())
flag = 0
seven = 0
if K % 2 != 0:
  for i in range(1000000):
    seven = seven * 10 + 7
    if seven % K == 0:
      ans = i + 1
      flag = 1
      break
else:
  flag = 2
if flag == 2:
  print(-1)
elif flag == 0:
  print(K-1)
else:
  print(ans)

Submission status: Time Limit Exceeded

Solution code:
k = int(input())

num = 1 
n = 7
 
while True:
  if (n%k == 0):
    print(num)
    break
  else:
    n = n*10 + 7
    num += 1

Submission status: Time Limit Exceeded

Solution code:
K = int(input())
j = 0
seven = 7
ans = 1

if(K%2 == 0):
    print(-1)
else:
    while K>seven:
        seven += 7*(10**ans)
        ans += 1
    while j ==0:
        if(seven%K == 0):
            j=1
        else:
            seven += 7*(10**ans)
            ans += 1
            
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys
import time
k=int(input())
start=time.time()
if k%2==0:
    print(-1)
    sys.exit()
num=7
cnt=1
while num%k!=0:
    num=num*10+7
    cnt+=1
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
k=int(input())
s="7"
ans=0
count=1
if k%2==0:
    print(-1)
else:
    
    while ans==0:
        if int(s)%k==0:
            ans=1
            print(count)
        else:
            s+="7"
            count+=1

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
k = int(input())
if k % 2 < 1 or k % 5 < 0:
    print(-1)
else:
    c = 1
    mod = 7 % k
    mop = 7 % k
    while mod > 0:
        mop = mop*10%k
        mod += mop
        mod %= k
        c += 1
    print(c)

Submission status: Time Limit Exceeded

Solution code:
a = int(input())
b = 7
c = 1
if a % 2 == 0 or a % 5 == 0:
  print(-1)
else:
  for i in range(1000000):
    if b % a == 0:
      print(c)
      break
    else:
      b = str(b) + "7"
      b = int(b)
      c += 1

Submission status: Time Limit Exceeded

Solution code:
k = int(input())

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

if k%7==0:
    k//=7

mod = 1
i=1
while mod%k!=0:
    mod+=pow(10,i,k)
    mod%=k
    i+=1
print(i)

Submission status: Time Limit Exceeded

Solution code:
import sys
n=int(input())
if n%2==0:
    print("-1")
    sys.exit()
s=['7']
while(True):
    if (int("".join(s),10)%n==0):
        print(len(s))
        break
    else:
        s.append('7')

Submission status: Time Limit Exceeded

Solution code:
K = int(input())
s = '7'
count = 1

if K % 2 == 0:
    print('-1')
else:
    while int(s) % K != 0:
        s = s + '7'
        count += 1
    print(count)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import re

k = int(input())

if k % 2 == 0:
  print(-1)
else:
  i = 1
  flg = True
  while flg:
    repatter = re.compile('^[7]+$')
    result = repatter.match(str(k * i))
    if result:
      print(len(str(k * i)))
      flg = False
    else:
      i += 1

Submission status: Time Limit Exceeded

Solution code:
K = int(input())

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

elif K%5 == 0:
    print(-1)

else:
    for i in range(1, 1000001):
        n = 7 * int('1'*i)
        if n%K == 0:
            print(i)
            break

Submission status: Time Limit Exceeded

Solution code:
k=int(input())
ans=1
mod=7%k
mod1=7%k
while mod1!=0:
  mod=(mod*10)%k
  mod1=mod1+mod
  if mod1>=k:
    mod1=mod1%k
  ans+=1
  
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
if n%2==0:
    print(-1)
elif n == 999983:
    print(999982)
else:
    length = len(str(n))
    res = "7"*length
    while True:
        if int(res)%n==0:
            break
        res+="7"
    print(len(res))

Submission status: Time Limit Exceeded

Solution code:
k = int(input())

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())
a=7
count=1
if K%2==0:
    print('-1')
else:
    while True:
        if a%K==0:
            break
        else:
            A=str(a)
            A+='7'
            a=int(A)
        count+=1
    print(count)

Submission status: Time Limit Exceeded

Solution code:
k = int(input())

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

if k%7==0:
    k//=7

mod = 1
i=1
while mod%k!=0:
    mod+=pow(10,i,k)
    i+=1
print(i)

Submission status: Time Limit Exceeded

Solution code:
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


def get_primes(n):
    root_n = int(n ** 0.5)
    is_prime = [True] * (n + 1)
    is_prime[0], is_prime[1] = False, False
    for i in range(2, root_n + 1):
        if not is_prime[i]:
            continue
        # i の倍数の素数判定をFalseにする
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]


def a(n):
    return 7 * (1 + ((10**n - 10) // 9))


INF = float('inf')


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

ans = 1
while True:
    if a(ans) % k == 0:
        break
    ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
k = int(input())
val = 7
if k%2 == 0:
    ans = -1
else:
    for i in range(1,10**12+1):
        if val >= k:
            sub = val % k
            if sub == 0:
                  ans = i
                  break
            else:
                  val = 10 * sub + 7
        else:
            val = 10 * val + 7
print(ans)

Submission status: Time Limit Exceeded

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


def solve(K: int):
    if K % 2 == 0:
        print(-1)
    else:
        num = 7
        cnt = 1
        while True:
            if num % K == 0:
                print(cnt)
                return
            else:
                num *= 10
                num += 7
                num %= K
                cnt += 1
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    solve(K)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
k = int(input())
t = '7'
i = 0
if k % 2 == 0:
    print(-1)
else:
    while(1):
        s = int(t)
        if s % k == 0:
            ans = i+1
            break
        t += '7'
        i += 1
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
if n%2==0:
    print('-1')
else:
    count=1
    k='7'
    while True:
        if int(k)%n==0:
            break
        count+=1
        
        k=k+'7'
    print(count)

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline
K = int(input())
flag = 0
seven = 0
if K % 2 != 0:
  for i in range(K):
    seven = seven * 10 + 7
    if seven % K == 0:
      ans = i + 1
      flag = 1
      break
if flag == 0:
  print(-1)
else:
  print(ans)

Submission status: Time Limit Exceeded

Solution code:
k = int(input())

flag = 7%k

i = 1
while True:
    tmp=int(''.join(map(str,[7]*i)))
    if tmp%k == 0:
        print(i)
        break
    if i > 1 and tmp%k == flag:
        print(-1)
        break
    i += 1

Submission status: Time Limit Exceeded

Solution code:
k = int(input())

s = 0

count = 0

while(True):
  s += 7*(10**count)
  count += 1
  if(s % k == 0):
    print(count)
    break

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
#200802C
X = int(input())
L = len(str(X))
#print(L)


Y = 0

for l in range(L):
    Y += 7*10**l
    
flag = 0
for i in range(10000000):
    Y = Y%X
    #print(i)

    if Y == 0:
        ans = L+i
        flag = 1
        break
    else: 
        Z = Y * 10 + 7
        if Z == Y:
            break
        else:
            Y = Z

if flag == 0:
    print("-1")
else:
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
t = int(input())
c = 1
N = 7
f=0

while(N%t !=0):
        c +=1
        N = N*10 + 7
        if(len(str(N))>10001):
            print(-1)
            f=1
            break
if(f!=1):
        print(c)

Submission status: Time Limit Exceeded

Solution code:
k = int(input())
n = '7'
cnt = 1
if k % 2 == 0:
    print(-1)
else:
    while cnt <= 100:
        num = int(n)
        if num%k == 0:
            print(cnt)
            break
        elif cnt == 100:
            print(k-1)
        else:
            cnt += 1
            n += '7'

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-

k = int(input())

if k < 1 or k % 2 == 0:
    print('-1')

for i in range(1, 10 ** 6):
    a = '1' * i
    a = 7 * int(a)

    if a % k == 0:
        print(i)
        exit()

print('-1')

Submission status: Time Limit Exceeded

Solution code:
k = int(input())
temp = True
for i in range(1, k+1):
  num = 7 * (int(pow(10,i)) - 1)
  if num%9 != 0:
      continue
  num = num//9
  #print(num)
  if num%k == 0:
    print(i)
    temp = False
    break
if temp:
  print("-1")

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
cnt = 0
res = 7
if(n % 2 == 0 or n % 5 == 0):
    print(-1)
else:
    while True:
        if(res % n == 0):
            print(cnt + 1)
            break
        else:
            res *= 10
            res += 7
            cnt += 1

Submission status: Time Limit Exceeded

Solution code:
import math
import sys
K  =int( input() )
seven = "7"
count = 1

for i in range (10**6):
    if int(seven) % K  == 0:
        print(count)
        sys.exit()

    else:
        count += 1
        seven = seven + "7"

print("-1")

Submission status: Time Limit Exceeded

Solution code:
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

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

ans = 1
seven = 7
mod = 7 % K
while True:
    if seven % K == 0:
        break
    ans += 1
    seven = (seven * 10) % K + mod
print(ans)

Submission status: Time Limit Exceeded

Solution code:
K = int(input())
t = 0
c = 0 
for i in range(K):
  t = t + 10**i
  s = 7 * t
  if K > s:
    pass
  else:
    if s%K==0:
      print(i + 1)
      c = c + 1
      break
    else:
      pass
if c == 0:
  print(-1)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
K = int(input())

if K % 2 == 0:
  print('-1')
else:
  x = 7
  count = 1
  while True:
    if x % K == 0:
      print(count)
      break
    else:
      x = 10*x + 7
      count += 1

Submission status: Time Limit Exceeded

Solution code:
k=int(input())
if k%10 in [2,4,5,6,8,0]:
  print(-1)
  exit()

for i in range(1,10**5):
  tmp=7*(10**i-1)//9
  if tmp%k==0:
    print(i)
    exit()
print(-1)

Submission status: Time Limit Exceeded

Solution code:
k=int(input())

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

Submission status: Time Limit Exceeded

Solution code:
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

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

ans = 1
seven = 7
mod = 7 % K
while True:
    if seven % K == 0:
        break
    ans += 1
    seven = (seven % K) * 10 + mod
print(ans)

Submission status: Time Limit Exceeded

Solution code:
k = int(input())

s = 7
i = 1
if k % 2 != 0:
    while s % k != 0:
        s += 7*10**i
        i += 1
    print(i)    
if k %2 == 0: 
    print(-1)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
K = int(input())
plus = 70
seven = 7
cnt = 1
if K%2 ==0:
    print(-1)
    exit(0)
for i in range(1000000):
    if seven%K == 0:
        print(cnt)
        exit(0)
    seven += plus*10**i
    cnt += 1

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
if n % 2 == 0:
	print(-1)
	exit(0)
cnt = 1
a = 7
while True:
	if a % n == 0:
		print(cnt)
		exit(0)
	cnt += 1
	a = a * 10 + 7

Submission status: Time Limit Exceeded

Solution code:
K = int(input())
count = 1
check = 7

if K % 2 == 0 or K % 5 == 0:
    print(-1)
else:
    while True:
        if check % K == 0:
            print(count)
            break
        else:
            count += 1
            check = check * 10 + 7

Submission status: Time Limit Exceeded

Solution code:
K = int(input())

ans = 0
judge = 0
sevens = []
for i in range(1,K+1):
    sevens.append(int("7"*i)%K)
if 0 in sevens:
    print(sevens.index(0) + 1)
else:
    print(-1)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
import sys 

readline = sys.stdin.readline

K = int(input())

seven_string = '7'
judge = False

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

for i in range(K + 1):
    seven_int = int(seven_string)
    if seven_int % K == 0:
        print(i+1)
        judge = True
        break

    seven_string += '7'

if not judge:
    print(-1)

Submission status: Time Limit Exceeded

Solution code:
k = int(input())

if k % 2 == 0:
    print(-1)
elif k % 5 == 0:
    print(-1)
else:
    ans = 1
    n = 7
    while n % k > 0:
        n = n*10 + 7
        ans += 1
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
K = int(input())

if K % 2 == 0:
	print(-1)
else:
	val = ''
	cnt = 0
	while True:
		val += '7'
		cnt += 1
		if int(val) % K == 0:
			break
	print(cnt)

Submission status: Time Limit Exceeded

Solution code:
from collections import defaultdict,deque
from sys import stdin,setrecursionlimit
import heapq,bisect,math,itertools,string,queue,copy
setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, stdin.readline().split()))


K = int(input())
def main():
    k = 7
    count = 1
    re = 1
    if K %2==0:
        print(-1)
        return
    while True:
        if k % K == 0:
            print(count)
            return
        re =  (re*10)%K
        k = (k+7*re)%K
        count += 1


main()

Submission status: Time Limit Exceeded

Solution code:
K = int(input())
ans = 0
ans1 = -1
if K%2 == 0:
  print(-1)
else:
  for i in range(30000):
    ans += 7*10**i
    if ans%K == 0:
      ans1 = i+1
      break
if ans1 == -1 and K%2 ==1:
  print(K-1)
elif K%2 == 1:
  print(ans1)

Submission status: Time Limit Exceeded

Solution code:
K = int(input())

N = 7
cnt =1

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

    while True:
        if K <= N:
            if N%K == 0:
                print(cnt)
                break

        N = N + 7*10**cnt
        cnt += 1

Submission status: Time Limit Exceeded

Solution code:

  
n = int(input())
if n%2==0:
  print(-1)
  exit()
#print(n_list)
seven = 7
while True:
  if n<=seven and seven%n==0:
    print(len(str(seven)))
    exit()
  seven = int(str(seven)+'7')
print(-1)

Submission status: Time Limit Exceeded

Solution code:
def main():

    K = int(input())
    # N, D = map(int, input().split())
    # A = [int(i) for i in input().split()]

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

    n = K
    while 1:
        # print(f"{n = }")
        if all([i == "7" for i in str(n)]):
            print(len(str(n)))
            break
        n += K


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
k = int(input())

num = 7
count = -1

if k%2 == 0:
    print(-1)
else:
    for i in range(1,1000000):
        if num%k == 0:
            count = i
            break
        num = num * 10 + 7
    print(count)

Submission status: Time Limit Exceeded

Solution code:
k = int(input())

if k % 2 == 0 or k % 5 == 0:
  print(-1)
else:
  i = int('7' * len(str(k)))
  while len(str(i)) < 10**6:
    if i % k == 0:
      print(len(str(i)))
      break
    i = int(str(i) + '7')

Submission status: Time Limit Exceeded

Solution code:

  
n = int(input())
if n%2==0:
  print(-1)
  exit()
#print(n_list)
seven = 7
while True:
  if n<=seven and seven%n==0:
    print(len(str(seven)))
    exit()
  seven = int(str(seven)+'7')
print(seven)
print(-1)

Submission status: Time Limit Exceeded

Solution code:
def check(K):
	if(K%2 == 0):
		return '-1'
	# if(K%7 == 0):
	# 	return '1'
	x = ['7' for i in range(10**6)]
	for i in range(1, 10**6):
		t = int(''.join(x[:i]))
		# print(t)
		if(t%K == 0):
			return i
	return '-1'

K = int(input())
s = check(K)
print(s)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
s = '7'
t = 0
for i in range(0, n):
    k = int(s)
    if (k % n == 0):
        print(len(s))
        t = 1
        break
    s = s + '7'
if (t == 0):
    print('-1')

Submission status: Time Limit Exceeded

Solution code:
k=int(input())
if k%2==0:
    print(-1)
    exit()
count=1
while True:
    if int('7'*count)%k==0:
        print(count)
        break
    count+=len(str(k))

Submission status: Time Limit Exceeded

Solution code:
k=int(input())
ans=[]
for i in range(1,10000000):
    if i==1:
        ans.append(7)
        if 7%k==0:
            print(1)
            exit()
    else:
        d=ans[i-2]+7*10**(i-1)
        ans.append(d)
        if d%k==0:
            print(i)
            exit()
print("-1")

Submission status: Time Limit Exceeded

Solution code:
k = int(input())
a = 0
if k % 2 == 0:
    print(-1)

for i in range(1000000):
    a += (10 ** i) * 7
    if a >= k and a % k == 0:
        print(i+1)
        break;

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin
import numpy as np
import sys
k = int(stdin.readline().rstrip())

num = 7
ans = 1
#2の偶数は弾く
if  k % 2 == 0 :
  print("-1")
  sys.exit()

while num <= 7**(10**6):
    #処理
    if  num % k == 0:
      break
    ans = ans + 1
    num = (num * 10) + 7
    #巨大数で割り切れなかった時
    if num > 7**(10**6):
      print("-1")
      sys.exit()
print(ans)

Submission status: Time Limit Exceeded

Solution code:
K = int(input())

def seven(s):
   t = ''
   for i in range(s):
      t = t + '7'
   return int(t)

result = -1

if not str(K)[-1] in ['0', '2', '4', '5', '6', '8']:
   count = 1
   while True:
      if seven(count) % K == 0:
         result = count
         break
      count = count + 1

print(result)

Submission status: Time Limit Exceeded

Solution code:
from sys import exit
k = int(input())
if (k%2) == 0:
  print('-1')
  exit()
num = 7
i = 0
while(1):
  if (num % k) == 0:
    print(i+1)
    exit()
  else:
    num = (num*10) + 7
  i += 1
print('-1')

Submission status: Time Limit Exceeded

Solution code:
def main():
    K = int(input())

    if K % 2 == 0:
        return -1
    elif K % 5 == 0:
        return -1

    an = ""

    while True:
        an = an + "7"

        if int(an)%K == 0:
            return len(an)

if __name__ == "__main__":
    answer = main()
    print(answer)

Submission status: Time Limit Exceeded

Solution code:
from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import product, combinations,permutations
from copy import deepcopy
from time import sleep
import sys
sys.setrecursionlimit(4100000)


def gen_seven(K):
    l = len(str(K))
    i = 1
    while True:
        yield  int('7'*(l+i-1))
        i += 1


if __name__ == '__main__':
    K = input()
    if(K[-1]==4 or K[-1]==5 or K[-1]==6 or K[-1]==8):
        print(-1)
        quit()
    else:
        KK = int(K)
        for i, s in enumerate(gen_seven(K)):
            if s%KK==0:
                print(i+1+len(K)-1)
                quit()

Submission status: Time Limit Exceeded

Solution code:
k = int(input())
a=7
b=10
while True:
  if a % k == 0:
    break
  else:
    a = a + 7*b
    b *= 10
print(len(str(b//10)))

Submission status: Time Limit Exceeded

Solution code:
k = int(input())
n = len(str(k))
if k%2 == 0 or k%5 == 0:
  print(-1)
  exit()

q = '7'
ans = 0
while True:
  if int(q) % k == 0:
    print(len(q))
    break
  for i in range(n):
    q += '7'

Submission status: Time Limit Exceeded

Solution code:
k = int(input())


def fun(k):
    i = 7
    count = 1
    if k % 2 == 0 or k % 2 == 5:
        return -1
    while True:
        if i % k == 0:
            return count
        else:
            i = i*10+7
            count += 1
    return -1


print(fun(k))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
s = '7'
t = 0
for i in range(0, 1000000):
    k = int(s)
    if (k % n == 0):
        print(len(s))
        t = 1
        break
    s = s + '7'
if (t == 0):
    print('-1')

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
if(n%2==0):
    print(-1)
else:
    a=7 
    ans=1
    flag=1  
    while(flag):
        if(a%n==0):
            print(ans)
            flag=0
            break 
        else:
            ans+=1 
            s=str(a)
            s1='7'
            s2=int(s+s1)
            a=int(s2)

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline
def I(): return int(input())

result = -1
num = 7
K = I()

if K % 2 == 0 or K %  5 == 0:
    print(-1)
    sys.exit()

for i in range(10**7):
    if num % K == 0:
        print(i+1)
        sys.exit()
    else:
        num += 7*10**(i+1)