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())
a=-1
b=0
for i in range(K):
    b+=7*10**i
    if(b%K==0):
        a=i+1
        break

print(a)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
k = int(input())

r = -1
for c in range(1, 1000000):
    if int('7' * c) % k == 0:
        r = c
        break

print(r)

Submission status: Time Limit Exceeded

Solution code:
K = int(input())

num = ""
cnt = 0
ans = False

while range(10000000):
    num = int(num + "7")
    cnt += 1
    if num % K == 0:
        ans = True 
        print(cnt)
        break
    else:
        num = str(num)
    
if ans == False :
    print(-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:
      print(count)
      break
    else:
      a=a*10+7
      count+=1

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
K = int(input())

if K%2==0 | K%2==5:
    print(-1)
else:
    s = 0
    loop = [0]

    for i in loop:
        s = s*10 + 7
        if s%K!=0:
            loop.append(i+1)
            continue
        print(i+1)
        break

Submission status: Time Limit Exceeded

Solution code:
K = int(input())

N = 7
count = -1

for i in range(K):
    amari = N%K
    if amari == 0:
        count = i+1
        break
    N = N*10 + 7
print(count)

Submission status: Time Limit Exceeded

Solution code:
import sys

K = int(input())

if K>10**6 or K<1 :
    print(-1)
    sys.exit()

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

while i:
    
    count += 1
    if N % K == 0:
        print(count)
        sys.exit()
    
    if count > K:
        print(-1)
        sys.exit()
    
    N = N*10 + 7

Submission status: Time Limit Exceeded

Solution code:
import sys

K = int(input())

if K>10**6 or K<1 :
    print(-1)
    sys.exit()

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

while i:
    
    count += 1
    if N % K == 0:
        print(count)
        sys.exit()
    
    if count > 10**6:
        sys.exit()
    
    N = N*10 + 7

Submission status: Time Limit Exceeded

Solution code:
import sys

K = int(input())

if K>10**6 or K<1 :
    print(-1)
    sys.exit()

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

while i:
    
    count += 1
    if N % K == 0:
        print(count)
        sys.exit()
        
    N = N*10 + 7

Submission status: Time Limit Exceeded

Solution code:
K = int(input())
number = 7
keta = 1
count = 1
while(1):
  num = number*keta
  if num % K ==0:
    print(count)
    break
  count += 1
  keta = keta*10+1
  if count == 10000000:
    print(-1)
    break

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
pos = 1
curr = 7
k = int(input())
while curr % k != 0:
  pos += 1
  k *= 10
  k += 7
print(pos)

Submission status: Time Limit Exceeded

Solution code:
K= int(input())

if K%2==0:
    print('-1')
else:
    t=True
    n=1
    a=7
    while t:
        if a%K!=0:
            a=(10*a+7)%K
            n+=1
        else:
            t=False
            print(n)

Submission status: Time Limit Exceeded

Solution code:
K= int(input())

if K%2==0:
    print('-1')
else:
    t=True
    n=1
    a=7
    while t:
        if a%K!=0:
            a=10*(a%K)+7
            n+=1
        else:
            t=False
            print(n)

Submission status: Time Limit Exceeded

Solution code:
k = int(input())
ans = 1
for i in range(1,10**10):
  a = '1'*i
  a = int(a)*7
  if a%k == 0:
    ans = i
    break
  else:
    ans = -1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
k = int(input())
a=0
n=0
for i in range (10**12):
  a+= 7*10**i
  n +=1
  if a%k ==0:
    print(n)
    break

Submission status: Time Limit Exceeded

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

k = int(input())

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

if k == 7:
    print(1)
    exit()

if k == 1:
    print(1)
    exit()

seven = 7
d = 1
while seven != 0:
    seven += pow(7*pow(10,d,k),1,k)
    seven = pow(seven,1,k)
    d += 1

print(d)

Submission status: Time Limit Exceeded

Solution code:
candidates = pow(10, 6)
K = int(input())
num = "7"
if K % 2 == 0:
    print (-1)
else:
    flag = False
    for i in range(candidates):
        if int(num) % K == 0:
            flag = True
            break
        num += "7"
    if flag:
        print (i + 1)
    else:
        print(-1)

Submission status: Time Limit Exceeded

Solution code:
K = int(input())

N=7
NotFound = True

for i in range(K):
  if N%K == 0:
    NotFound = False
    print(i+1)
    break
  N=N*10+7

if (NotFound):
  print(-1)

Submission status: Time Limit Exceeded

Solution code:
import sys

k = int(input())
result = -1
count = 0
seven = 0
remainder = 0
aryRemainder = []

if k%2 == 0:
  print(result)
  sys.exit()

while not(remainder in aryRemainder):
  aryRemainder.append(remainder)
  seven = seven*10+7
  count += 1
  remainder = seven % k
  if remainder == 0:
    result = count
    break
  

print(result)

Submission status: Time Limit Exceeded

Solution code:
K=int(input())
num=7
i=1
d=[]
while 1:
  num=num%K
  if num==0:
    print(i)
    break
  if num in d:
    print(-1)
    break
  d.append(num)
  num = 10*num + 7
  i+=1

Submission status: Time Limit Exceeded

Solution code:
k=int(input())
lst=[]
string=""
b=0
c=0
for c in range(10**6):
    string+='7'
    lst.append(string)
multiples=[]
a=1
m=0
while(a<10**6):
    multiples.append(k*a)
    a+=1
for z in multiples:
    if z in lst:
        print(lst.index[z])
        m=1
if(m==0):
    print(-1)

Submission status: Time Limit Exceeded

Solution code:
k = int(input())
x = 0
ans = -1
if k % 2 == 1:
    for i in range(10**7):
        x = (x + 7 * pow(10, i, k)) % k
        if x == 0:
            ans = i + 1
            break
print(ans)

Submission status: Time Limit Exceeded

Solution code:
K = int(input())

a = 7

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

else:
    print(-1)

Submission status: Time Limit Exceeded

Solution code:
count = 1
val = int(input())
if val % 2 == 0:
	print("-1")
else:
	while True:
		l = ["7" for i in range(count)]
		sl = "".join(l)
		if int(sl) % val == 0:
			print(len(sl))
			break
		else:
			count += 1

Submission status: Time Limit Exceeded

Solution code:
import sys
K = int(input())

t = 7
for i in range(K):
    if t % K == 0:
        print(i + 1)
        break
    t = t*10+7
else:
    print(-1)

Submission status: Time Limit Exceeded

Solution code:
k = int(input())

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

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
if N%2==0:
  print(-1)
else:
  ans=1
  a=7
  num=7
  while(num%N!=0):
    a=(a*10)%N
    num=(num+a)%N
    ans+=1
  print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys

K = int(input())
a = 7
for i in range(K):
    if a % K == 0:
        print(i+1)
        sys.exit()
    a = 10 * a + 7
print(-1)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
def Calculator(K):
    a =[0]*K
    a[0] = 7
    if a[0] % K == 0:
        return (1)
    for i in range(1,K):
        a[i] = 10 * a[i-1] + 7
        if a[i] % K == 0:
            return (i+1)
    return -1
K = int(input())
print(Calculator(K))

Submission status: Time Limit Exceeded

Solution code:
import sys
K=int(sys.stdin.readline().strip())
a=0
for i in range(10**7):
    a+=7*pow(10,i,K)
    a%=K
    if a==0:
        print i+1
        quit()
else:
    print -1

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
K = int(input())

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
ans = None

if n%2 == 0:
    ans = -1
else:
    i = 1
    while ans is None:
        t = int('7'*i)
        i += 1
        if t%n == 0:
            ans = i - 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
k = int(input())

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

lenK = len(str(k))

s = ""
for i in range(lenK):
    s += "7"
s = int(s)
cnt = lenK

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

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
# Your code here!

K = int(input())

Sequence = 0
flag = 0
for i in range(K) : 
    Sequence += 7*(10**i)

    if Sequence % K == 0 : 
        flag = 1
        break

if flag == 1 : 
    print(i+1)
else : 
    print(-1)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
k = int(input())
n = 7
cnt = 1
while True:
    if (n % k) == 0:
        break
    n = int(str(n) + "7")
    cnt += 1
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
k = int(input())
target = 7
if k % 2 == 0:
  print(-1)
  exit()
for i in range(1000000 + 1):
  if target % k == 0:
    print(i + 1)
    exit()
  target *= 10
  target += 7
print(-1)

Submission status: Time Limit Exceeded

Solution code:
k = int(input())

n = 1
m = 7
while True:
  if k == 2:
    print('-1')
    exit()
  if m % k != 0:
    n += 1
    m += 7*(10**(n-1))
  else:
    print(n)
    exit()

Submission status: Time Limit Exceeded

Solution code:
k = int(input())
if k % 10 == 5 or k % 2 == 0:
    print(-1)
else:
    t = 0
    sur_p = 7 * (10**0)
    while t>=0:
        if sur_p % k == 0:
            print(t+1)
            break           
        t += 1
        sur_p += 7 * (10**t)

Submission status: Time Limit Exceeded

Solution code:
k = int(input())
n = 7

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

ans = 1
while True:
    if n % k == 0:
        print(ans)
        exit()
    n = (n*10 + 7)
    ans += 1

Submission status: Time Limit Exceeded

Solution code:
k = int(input())
has_multi = False
for i in range(1,1000000):
    if int("7" * i) % k == 0:
        print(i)
        has_multi = True
        break

if not has_multi:
    print(-1)

Submission status: Time Limit Exceeded

Solution code:
num = int(input())
if num % 2 == 0 | num % 5 == 0:
    ans = -1
else:
    like_num = 7
    ans = 1
    while like_num % num != 0:
        like_num = like_num * 10 + 7
        ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
k=int(input())
q=[k+1]*k
i=1
seven=7
while seven%k!=0:
    if seven%k in q:
        print(-1)
        break
    q[i-1]=seven%k
    seven+=7*(10**i)
    i+=1    
else:print(i)

Submission status: Time Limit Exceeded

Solution code:
k=int(input())
s=7
x=10000000
for i in range(x):
    if(s%k==0):
        print(i+1)
        break
    s=(s%k)*10+7
if(s%k!=0):
    print("-1")

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
K = int(input())
if K % 2 == 0 :
    print('-1')
elif K % 5 == 0 :
    print('-1')
else:
    n = 0
    for i in range(1000000):
        n = n * 10 + 7
        if n % K == 0:
            print(i+1)
            break
    else:
        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:
        break
    a = (a * 10) + 7
    count += 1
if count == K + 1:
    print(-1)
else:
    print(count)

Submission status: Time Limit Exceeded

Solution code:
k = int(input())
a = []

for  i in range(k+1):
    if i == 0:
        a.append(7%k)
    else:
        a.append((10*a[i-1] + 7)%k)
        if a[i] in a[:i-1]:
            break

if 0 in a:
    print(a.index(0)+1)
else:
    print('-1')

Submission status: Time Limit Exceeded

Solution code:
K = int(input())
S = 7

for i in range(K+1):
    if int(S) % K != 0:
        S = S * 10 + 7
    else:
        print(i+1)
        break

if i >= K:
    print('-1')

Submission status: Time Limit Exceeded

Solution code:
K = int(input())
S = 7
if (1 <= K) and (K <= (10 ** 6)):

    for i in range(K+1):
        if int(S) % K != 0:
            S = S * 10 + 7
        else:
            print(i+1)
            break

    if i >= K:
        print('-1')

Submission status: Time Limit Exceeded

Solution code:
K = int(input())
S = 7
i = 1
if (1 <= K) and (K <= (10 ** 6)):
    while True:
        if int(S) % K != 0:
            S = S * 10 + 7
            i += 1
        else:
            print(i)
            break

        if i > K:
            print('-1')
            break

Submission status: Time Limit Exceeded

Solution code:
K = int(input())
S = 7
i = 1
if (1 <= K) and (K <= (10 ** 6)):
    while True:

        if int(S) % K != 0:
            S = S * 10 + 7
            i += 1
        elif i > K:
            break
        else:
            break
    print(i)
else:
    pass

Submission status: Time Limit Exceeded

Solution code:
K = int(input())
S = 7
i = 1
if (1 <= K) and (K <= (10 ** 6)):
    while True:

        if int(S) % K != 0:
            S = S * 10 + 7
            i += 1
        elif i > K:
            break
        else:
            break
    print(i)
else:
    print('"K" is out of range!')

Submission status: Time Limit Exceeded

Solution code:
K = int(input())
S = '7'
i = 1
if (1 <= K) and (K <= (10 ** 6)):
    while True:

        if int(S) % K != 0:
            S += '7'
            i += 1
        elif i > K:
            break
        else:
            break
    print(i)
else:
    print('"K" is out of range!')

Submission status: Time Limit Exceeded

Solution code:

K = int(input())
S = '7'
i = 1
try:
    if (1 <= K) and (K <= (10 ** 6)):
        while True:

            if int(S) % K != 0:
                S += '7'
                i += 1
            else:
                break
        print(i)
    else:
        print('"K" is out of range!')
except Exception as e:
    print(e)

Submission status: Time Limit Exceeded

Solution code:

K = int(input())
S = '7'
i = 1
if (1 <= K) and (10 ** 6):
    while True:

        if int(S) % K != 0:
            S += '7'
            i += 1
        else:
            break

print(i)

Submission status: Time Limit Exceeded

Solution code:
k = int(input())
answer = -1
cou = 7
for i in range(k+1):
	if cou%k == 0:
		answer = i+1
		break
	else:
		cou = cou*10 + 7
print(answer)

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline
m = 1e9 + 7
def inp():
    return(int(input()))

def solve():
    k = inp()
    if k%2 == 0 and k%5 == 0:
        return -1
    else:
        s = 7%k
        ans = 1
        while s > 0:
            s = (s*10 + 7)%k
            ans += 1
            
    return ans

print(solve())

Submission status: Time Limit Exceeded

Solution code:
k = int(input())
n = 7
ans = 1
for _ in range(1000000):
  if n % k == 0:
    print(ans)
    exit()
  else:
    n = 10*n + 7
    ans += 1
print('-1')

Submission status: Time Limit Exceeded

Solution code:
def solve(k):
    a_mod = 0
    for i in range(1000000):
        a_mod += 7 * pow(10, i, k)
        a_mod %= k
        if a_mod == 0:
            return i + 1
    return -1


def main():
    k = int(input())
    res = solve(k)
    print(res)


def test():
    assert solve(101) == 4
    assert solve(2) == -1
    assert solve(999983) == 999982


if __name__ == "__main__":
    test()
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
num = 7
k = int(input())
count=1
# i=1
while(True):
    if(num%k==0):
        print(count)
        break
    if(count>k):
        print(-1)
        break
    num = num*10+7
    count+=1

Submission status: Time Limit Exceeded

Solution code:
import sys
#DEBUG=True
DEBUG=False
num=7
if DEBUG:
    f=open("C_input.txt")
else:
    f=sys.stdin
N=int(f.readline().strip())
mod_sum=0
ind=1
pdt=1
if N%2==0:
    print("-1")
else:
    mod_sum=num%N
    if not mod_sum:
        print(ind)
    else:
        while True:
            pdt*=10
            tmp=(num*pdt)%N
            mod_sum=(mod_sum+tmp)%N
            ind+=1
            if not mod_sum:
                print(ind)
                break
f.close()

Submission status: Time Limit Exceeded

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

def inp():
    return(int(input()))

def solve():
    k = inp()
    if k%2 == 0 and k%5 == 0:
        return -1
    else:
        s = 7%k
        ans = 1
        while s!=0:
            s = s*10 + 7
            s = s%k
            ans += 1
    return ans

print(solve())

Submission status: Time Limit Exceeded

Solution code:
import sys


a = int(input())

cur = 0
for i in range(1, 10 ** 7):
	#b = sum([(7 * (10**x)) for x in range(i + 1)])
    cur *= 10
    cur += 7
    cur %= a
    if cur == 0:
        print(i)
        sys.exit()
print(-1)

Submission status: Time Limit Exceeded

Solution code:
import sys


a = int(input())

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

n = 7
i = 0
for f in range(a):
	b = sum([(7 * (10**x)) for x in range(i + 1)])
	if b % a == 0:
		print(i + 1)
		sys.exit()
	else:
		i = i + 1

Submission status: Time Limit Exceeded

Solution code:
k=int(input())
n=7
cnt = 1
a=-1
for i in range(1,k+1): 
	if n % k == 0:
		a=i	
		break
	else:
		n = n * 10 + 7 
		i = i + 1

print(str(a))

Submission status: Time Limit Exceeded

Solution code:
a = int(input())

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

n = 7
i = 0
while True:
	b = sum([(7 * (10**x)) for x in range(i + 1)])
	if b % a == 0:
		print(i + 1)
		exit()
	else:
		i = i + 1

Submission status: Time Limit Exceeded

Solution code:
import sys
K=int(input())
L=9*K
if L%7==0:
  L = L//7
for i in range(1,K+1):
  if 10 ** i % L == 1:
    print(i)
    sys.exit()
print(-1)

Submission status: Time Limit Exceeded

Solution code:
K=int(input())
def amari2(a):
  return a % 2
def amariK(a):
  return a % K
ii=0
if amari2(K)==0:
  print(-1)
else:
  for i in range(10**1000):
    ii=amariK(ii+amariK(10**i))
    if amariK(7*ii)==0:
      break
  print(i+1)

Submission status: Time Limit Exceeded

Solution code:
k = int(input())

ans = []
memo = 0
for i in range(k):
    memo = 10*memo + 7
    if memo % k == 0:
        ans.append(i)
print(-1 if not len(ans) else ans[0] + 1)

Submission status: Time Limit Exceeded

Solution code:
k = int(input())

li = []

for i in range(k):
    li.append(int('7'*(i+1)) % k)
count = -1
for i in range(k):
    if(li[k-i-1] == 0):
        count = k-i

print(count)

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
K = int(input())
s = "7" * (len(str(K))-1)
cnt = len(s)
if K%2==0 or str(K)[-1]=="5":
    print(-1)
    exit()
for k in range(K):
    if k==0:
        sevens = 7
    else:
        sevens = sevens * 10 + 7
    if sevens%K==0:
        print(k+1)
        exit()
print(-1)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

def main():
    
    K = I()
    
    if K%2 == 0:
        print('-1')
        sys.exit()
    
    ans = len(str(K))
    while 1:
        
        num = int('7'*ans)
        
        if num%K == 0:
            print(ans)
            break
        
        ans += 1

main()

Submission status: Time Limit Exceeded

Solution code:
def main():
    
    K = int(input())
    if K%2 == 0:
        print('-1')
        exit()
    
    ans = len(str(K))
    while 1:
        
        num = int('7'*ans)
        
        if num%K == 0:
            print(ans)
            break
        
        ans += 1

main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
K = int(input())

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

r = 1
N = 0

while True:
    N += 7*(10**(r-1))
    if N%K ==0:
        break
    r += 1

print(r)

Submission status: Time Limit Exceeded

Solution code:
K = int(input())

r = 1
N = 0
while True:
    N += 7*(10**(r-1))
    if N%K ==0:
        break
    r += 1

print(r)

Submission status: Time Limit Exceeded

Solution code:
k = int(input())
i = 1
a = 7
a %= k
while a != 0:
  i += 1
  a = (10*a + 7) % k
  if i == 10**9+7:
    i = -1
    break

print(i)

Submission status: Time Limit Exceeded

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

  print(i)

Submission status: Time Limit Exceeded

Solution code:
flg_stop = False
count = 1

K = int(input())

if K % 2 == 0:
    count = -1
    flg_stop = True
else:
    if K % 7 == 0:
        L = 9 * K / 7
    else:
        L = 9 * K

    mod_ = 1
    while not(flg_stop):
        mod_ = (mod_ * 10) % L
        if mod_ == 1:
            flg_stop = True
            continue
        count += 1

print(count)

Submission status: Time Limit Exceeded

Solution code:
k = int(input())
i = 1
a = 7
while a % k != 0:
  i += 1
  a = 10*a + 7
  if i == 10**9+7:
    i = -1
    break

print(i)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:

num = 7
K = int(input())

flg_stop = False
count = 1

if K % 2 == 0:
    count = -1
    flg_stop = True


while not(flg_stop):
    mod_ = num % K
    if mod_ == 0:
        flg_stop = True
        continue
    num_2 = 7 * 10 ** count
    mod_2 = num_2 % K
    num = mod_ + mod_2
    count += 1

print(count)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
k = int(input())
num = 7 
s = set()
cnt = 1
while(1):
    m = num%k
    if m == 0:
        print(cnt)
        break
    elif m in s:
        print(-1)
        break
    else:
        s.add(m)
    num = num*10+7
    cnt += 1

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin
input = stdin.buffer.readline
k = int(input())
t, c = 7, 1
while t % k:
    t = t * 10 + 7
    c += 1
print(c)

Submission status: Time Limit Exceeded

Solution code:
K = int(input())
a = 7
cnt = 1
for k in range(K):
    if a % K == 0:
        print(cnt)
        exit()
    else:
        cnt += 1
        a = a * 10 + 7
else:
    print("-1")

Submission status: Time Limit Exceeded

Solution code:
K = int(input())
reminders = []
for i in range(1,K*10):
  reminder = int(str(7)*i)%K
  if reminder == 0:
    print(i)
    break
  elif reminder in reminders:
    print('-1')
    break
  else:
    reminders.append(reminder)

Submission status: Time Limit Exceeded

Solution code:
def main():
  s = input()
  k = int(s)
  if k % 2 == 0:
    print("-1")
    exit(0)
  kurai = 1
  count = 1
  sevens = 0
  while True:
    sevens = sevens + 7 * kurai
    if sevens % k == 0:
      print(str(count))
      break
    else:
      count+=1
      kurai = kurai * 10

if __name__ == "__main__":
  main()

Submission status: Time Limit Exceeded

Solution code:
k = int(input())
 
ans = -1
n = 7
for i in range(k):
  if n % k == 0:
    ans=i+1
    break
  n = n * 10 + 7
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
K=int(input())
if K%2 == 0 or K%5 == 0:
  print(-1)
else:
  base = ''
  count = 1
  while(1):
    base += '7'
    if int(base)%K == 0:
      print(count)
      break
    else:
      count += 1
    if count > K:
      print(-1)
      break

Submission status: Time Limit Exceeded

Solution code:
ma = lambda :map(int,input().split())
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
import collections
import math
import itertools
import heapq as hq
k = ni()
a = 0
for i in range(10**7):
    a=(a+7*pow(10,i,k))%k
    if a== 0:
        print(i+1)
        exit()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
K=int(input())
if K%2 == 0 or K%5 == 0:
  print(-1)
else:
  base = ''
  count = 1
  while(1):
    base += '7'
    if int(base)%K == 0:
      print(count)
      break
    else:
      count += 1

Submission status: Time Limit Exceeded

Solution code:
K = int(input())

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

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

Submission status: Time Limit Exceeded

Solution code:
K = int(input())

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

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

Submission status: Time Limit Exceeded

Solution code:
K = int(input())

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

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

Submission status: Time Limit Exceeded

Solution code:
K = int(input())

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

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

Submission status: Time Limit Exceeded

Solution code:
K = int(input())

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

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

Submission status: Time Limit Exceeded

Solution code:
K = int(input())
count = 0
an = 0

if K%2 == 0 or K%2 ==0:
    print("-1")
    exit(0)
while True:
  an = (10*an + 7) % K
  count +=1
  if an == 0:
     break
print(count)

Submission status: Time Limit Exceeded

Solution code:
K = int(input())
count = 0
an = 0

if K%2 == 0 or K%2 ==0:
    print("-1")
    exit()
while True:
  an = (10*an + 7) % K
  count +=1
  if an == 0:
    print(count)
    break

Submission status: Time Limit Exceeded

Solution code:
K = int(input())
c = 0
an = 0

if K%2 == 0 or K%2 ==0:
    print("-1")
    exit(0)
while True:
  an = (10*an + 7) % K
  c +=1
  if an == 0:
    print(c)
    break

Submission status: Time Limit Exceeded

Solution code:
K = int(input())
count = 0
an = 0

if K%2 == 0 or K%2 ==0:
    print("-1")
    exit(0)
while True:
  an = (10*an + 7) % K
  count +=1
  if an == 0:
    print(count)
    break

Submission status: Time Limit Exceeded

Solution code:
K = int(input())
count = 0
an = 0

if K%2 == 0 or K%2 ==0:
    print("-1")
    exit(0)
while True:
  an = 10*an + 7
  count +=1
  if an % K == 0:
    print(count)
    break

Submission status: Time Limit Exceeded

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

if K%2 == 0 or K%2 ==0:
    print("-1")
    exit(0)
while True:
  if an % K == 0:
    print(count)
    exit(0)
  an = 10*an + 7
  count +=1

Submission status: Time Limit Exceeded

Solution code:
k = int(input())
if k%2 == 0:
    print(-1)
else:
    seven = ''
    for i in range(1,10000000):
        seven += '7'
        if int(seven)%k == 0:
            break
    print(i)

Submission status: Time Limit Exceeded

Solution code:
K = int(input())

def calculate(k):

    res = 1

    n = 7

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

    if k % 5 == -1:
        print(-1)
        return

    while n % k > 0:
        n = n % k
        n = n * 10 + 7
        res += 1

    print(res)

calculate(K)