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: Wrong Answer

Solution code:
K = int(input())
seven = 7
count = 0

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

        # これだと10^5以降の計算が遅くなる。countのせい？？
        # count += 1
        # seven = seven + 7 * (10 ** count)

if(count >= 1): 
    print(count + 1)

Submission status: Wrong Answer

Solution code:
k = int(input())
c = 0
start = 7
while c<=k:
    if start == 0:
        break
    c+=1
    start = (start*10+7)%k
if c>k:
    print(-1)
else:
    print(c+1)

Submission status: Wrong Answer

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


def main():
    K = I()
    result = -1
    num = 1
    if K % 2 == 0 or K %  5 == 0:
        print(-1)
        exit()
    if K % 7 == 0:
        K = 9*K//7
    else:
        K = 9*K
    for i in range(10**6):
        num *= 10
        if num % K == 1:
            print(i+1)
            exit()

Submission status: Wrong Answer

Solution code:
n = int(input())
if n%2==0:
    print(-1)
elif n%5==0:
    print(-1)
else:
    k=7
    while k%n!=0:
        k*=10
        k+=7
        if k%n==0:
            print(len(str(k)))
            break

Submission status: Wrong Answer

Solution code:
k = int(input())
 
s = 7
for i in range(1, k):			# rangeの上限がk
    if s % k == 0:
        print(i)
        break
    else:
    	s = (s * 10 + 7) % k	# %kが難しい
else:				 			# for文にもelseが使える
    print(-1)

Submission status: Wrong Answer

Solution code:
k = int(input())

seven = 7
for i in range(1, k):                   #rangeの上限がk
    if seven % k == 0:
        print(i)
        break
    seven = (seven * 10 + 7) % k        # %kが難しい
else:                                   # for文にもelseが使える
    print(-1)

Submission status: Wrong Answer

Solution code:
K = int(input())
i = 1
y = 1
if K%2 == 0 or K%5 == 0:
  print(-1)
#elif K%3 == 0:
#  print(3)
elif K== 7:
  print(1)
else:
  if K%7 == 0:
    K = K//7
  while True:
    i += 1
    y = ((y*10)%K) + 1
    y = y%K
    if y == 0:
      break
  print(i)

Submission status: Wrong Answer

Solution code:
k = int(input())

l = 0
if k % 7 == 0:
    l = 9 * k // 7
else:
    l = 9 * k

for i in range(1, k):
    m = pow(10, i, l)
    if m == 1:
        print(i)
        break
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
k = int(input())
b = 7
c = 1
a = []
a.append(7)
if(k%2 == 0):
  print(-1)
else:
  while(b%k != 0):
    r = b%k
    b = 10*r+7
    c += 1
    if(c > k):
      print(-1)
    else:
      print(c)

Submission status: Wrong Answer

Solution code:
def main():
    k = int(input())
    num = 1
    n = 7

    if (k % 2 == 0):
        print(-1)
        return
    
    for i in range(100000):
        if (n % k == 0):
            print(num)
            return
        else:
            n = (n*10 + 7) %k
            num += 1
    print(-1)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

now=1
cnt=1
mae=0
if k%2==0:
  print(-1)
  sys.exit()


for i in range(2*10**6):
  now=(10*mae+7)%k
  if now%k==0:
    print(i+1)
    break
  else:
    mae=now%k

Submission status: Wrong Answer

Solution code:
def main():
    k = int(input())
    num = 1
    n = 7

    if (k % 2) == 0:
        print(-1)
        return
    
    for i in range(100000):
        if (n % k == 0):
            print(num)
            return
        else:
            n = (n*10 + 7) %k
            num += 1
    print(-1)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

now=1
cnt=1
mae=0
if k%2==0:
  print(-1)
  sys.exit()


for i in range(2*10**6):
  now=(10*mae+7)%k
  if now%k==0:
    print(i+1)
    break
  else:
    mae=now

Submission status: Wrong Answer

Solution code:
k = int(input())

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

seven = 7
for i in range(1, k):                   #rangeの上限がk
    if seven % k == 0:
        print(i)
        break
    seven = (seven * 10 + 7) % k        # %kが難しい
else:                                   # for文にもelseが使える
    print(-1)

Submission status: Wrong Answer

Solution code:
k = int(input())
b = 7
c = 1
a = []
a.append(7)
if(k%2 == 0):
  print(-1)
else:
  while(b%k != 0):
    r = b%k
    b = 10*r+7
    c += 1
  if b in a:
    print(-1)
  a.append(b)
  print(c)

Submission status: Wrong Answer

Solution code:
k = int(input())
b = 7
c = 1
a = []
a.append(7)
if(k%2 == 0):
  print(-1)
else:
  while(b%k != 0):
    r = b%k
    b = 10*r+7
    c += 1
  if b in a:
    print(-1)
  else:
  	a.append(b)
  	print(c)

Submission status: Wrong Answer

Solution code:
k = int(input())
num = 0
ans = 0
seven = ''


for i in range(k):
    seven += '7'
    num = int(seven) % k
    if num == 0:
        ans = i
        break
print(ans)

Submission status: Wrong Answer

Solution code:
k = int(input())
x = 7%k
s = []

while s.count(x) == 0:
  s.append(x)
  if x == 0:
    print(len(s))
    break
  x = (10*x + 7)%k

  
if s.count(x) != 0:
  print(-1)

Submission status: Wrong Answer

Solution code:
k = int(input())

def k_multipul_at(k: int) -> int:
  r = 7 % k
  cache = [r, 0]
  i = 1
  while r not in cache:
    r = (r * (10 % k) + 7 % k) % k
    cache.append(r)
    i += 1
  return -1 if r else i

print(k_multipul_at(k))

Submission status: Wrong Answer

Solution code:
k = int(input())
x = 7%k
s = []
if k%2 == 0:
  print(-1)

else:
  while s.count(x) == 0:
    s.append(x)
    if x == 0:
      print(len(s))
      break
    x = (10*x + 7)%k

  
  if s.count(x) != 0:
    print(-1)

Submission status: Wrong Answer

Solution code:
from math import log10

K = int(input())
  
def find(K):
  if K % 2 == 0 or K % 5 == 0:
    return -1
  
  if K % 7 == 0:
    L = K * 9 // 7
  else:
    L = K * 9

  count = int(log10(L))
  
  quotient = 10**count % L
  
  while True:
    if quotient == 1:
      return count
    quotient = quotient * 10 % L
    count += 1
    
    
print(find(K))

Submission status: Wrong Answer

Solution code:
k = int(input())

def k_multipul_at(k: int) -> int:
  r = 7 % k
  cache = [r]
  i = 1
  while r not in cache and r:
    r = r * (10 % k) + 7 % k
    cache.append(r)
    i += 1
  return -1 if r else i

print(k_multipul_at(k))

Submission status: Wrong Answer

Solution code:
k = int(input())
x = 7%k
s = []
if k%2 == 0:
  print(-1)

else:
  while s.count(x) == 0:
    s.append(x)
    if x == 0:
      print(len(s))
      break
    s.append(x)
    x = (10*x + 7)%k

  
  if s.count(x) != 0:
    print(-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
k = int(input())

ok=False
if(k%7==0):
    k=k//7
for i in range(k):
    if((k-1)%(i+1)!=0):
        continue
    val = "1"*(i+1)
    num = int(val)
    if(num%k==0):
        print(i+1)
        ok=True
        break
if(not ok):
    print(-1)

Submission status: Wrong Answer

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

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

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

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
K = int(input())
i = 1
y = 1
if K%2 == 0 or K%5 == 0:
  print(-1)
elif K%3 == 0:
  print(3)
elif K == 999983:
  print(999982)
else:
  if K%7 == 0:
    K = K//7
  while True:
    i += 1
    y = ((y*10)%K) + 1
    y = y%K
    if y == 0:
      break
  print(i)

Submission status: Wrong Answer

Solution code:
k = int(input())

def k_multipul_at(k: int) -> int:
  r = 7 % k
  cache = [r]
  i = 1
  while r not in cache and r:
    r = (r * 10 + 7) % k
    cache.append(r)
    i += 1
  return -1 if r else i

print(k_multipul_at(k))

Submission status: Wrong Answer

Solution code:
import math
t = int(input())
if t%2==0 or t%5==0:
    print(-1)
else:
    i=1
    s=7%t
    while 1:
        if (s%t)==0:
            print(i)
            break
        i += 1

        s = (s * 10 + 7)%t
        print(s)
        continue

Submission status: Wrong Answer

Solution code:
k = int(input())

def k_multipul_at(k: int) -> int:
  r = 7 % k
  cache = [7]
  i = 1
  while r not in cache and r:
    r = (r * 10 + 7) % k
    cache.append(r)
    i += 1
  return -1 if r else i

print(k_multipul_at(k))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
K = int(input())
i = 1
y = 1
if K%2 == 0 or K%5 == 0:
  print(-1)
elif K%3 == 0:
  print(3)
elif K == 999983:
  print(999982)
else:
  if K%7 == 0:
    K = K//7
  while True:
    i += 1
    y = ((y*10)%K) + 1
    if y%K== 0:
      break
  print(i)

Submission status: Wrong Answer

Solution code:
#  mod Nの取りうる値の上限はN-1なのでN-1回のループで解が出なければ-1でいい
#  modの値が同じになった場合ループになるためexitする

K = int(input())

mod = 7 % K

res = []

i = 1

while res.count(mod) == 0:
    if mod == 0:
        print(i)
        exit()

    res.append(mod)
    mod = (mod * 10 + 7) % K
    i += 1

Submission status: Wrong Answer

Solution code:
b = int(input())

list = [7]
for i in range(b):
    list.append(list[-1]*10 +7)

for l in range(b%10, len(list)):
    if list[l] % b == 0:
        print(b%10 + l)
        exit()

Submission status: Wrong Answer

Solution code:
k = int(input())

def k_multipul_at(k: int) -> int:
  r = 7
  cache = [7]
  i = 0
  while r not in cache and r:
    r = (r * 10 + 7) % k
    cache.append(r)
    i += 1
  return -1 if r else i

print(k_multipul_at(k))

Submission status: Wrong Answer

Solution code:
a = 7
b = int(input())
 
list = [7]
for i in range(b):
    list.append(list[-1]*10 +7)
 
for l in range(len(list)):
    if list[l] % b == 0:
        print(l+1)
        exit()

Submission status: Wrong Answer

Solution code:
#  mod Nの取りうる値の上限はN-1なのでN-1回のループで解が出なければ-1でいい
#  modの値が同じになった場合ループになるためexitする

K = int(input())

mod = 7 % K

res = []

for i in range(1, K):
    if mod == 0:
        print(i)
        exit()

    if mod in res:
        print(-1)
        exit()

    res.append(mod)
    mod = (mod * 10 + 7) % K

Submission status: Wrong Answer

Solution code:
k=int(input())
flag=True
if k%2==0 or k%5==0:
  print(-1)
else:
  val = 7
  for i in range(0,(10**7)):
    if val%k==0:
      print(i+1)
      flag=False
      break
    val = (val * 10 + 7)

if flag:
  print(-1)

Submission status: Wrong Answer

Solution code:
#n, m = map(int,input().split())
k = int(input())
#hl = list(map(int,input().split()))

s = len(str(k))



for i in range(1,k+1):
    if int('7'*i) % k == 0:
        print(i+1)
        exit()
print(-1)

Submission status: Wrong Answer

Solution code:
K = int(input())

res = -1
count = 1
sum = 7
prev = []
r = sum % K
while(r not in prev):
    prev.append(r)
    sum = sum * 10 + 7
    r = sum % K
    if(r == 0):
        res = count+1
        break
    count += 1

print(res)

Submission status: Wrong Answer

Solution code:
K = int(input())
if K % 2 == 0 or K % 5 == 0:
    print(-1)

cnt = 1
cur = 7
while True:
    if cur % K == 0:
        print(cnt)
        break
    if cnt > K:
        print('-1')
        break
    cur = (cur * 10 + 7) % K
    cnt += 1

Submission status: Wrong Answer

Solution code:
k = int(input())

def k_multipul_at(k: int) -> int:
  r = 7
  cache = [7]
  i = 0
  while r not in cache or r:
    r = (r * 10 + 7) % k
    cache.append(r)
    i += 1
  return -1 if r else i

print(k_multipul_at(k))

Submission status: Wrong Answer

Solution code:
K=int(input())
n = 0
seven=7
while n<=K:
    seven += ((7*10)*n)
    if seven%K==0:
        print(n)
        break
    n+=1
    if n ==K:
        if seven%K==0:
            print(n)
        else:
            print(-1)

Submission status: Wrong Answer

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

cnt = 1
cur = 7
while True:
    if cur % K == 0:
        print(cnt)
        break
    a = K * cur
    b = str(a)
    b_set = set(b)
    if cnt > K:
        print('-1')
        break
    cur = (cur % K) * 10 + 7
    cnt += 1

Submission status: Wrong Answer

Solution code:
k = int(input())

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

for i in range(1, k):
    if num % k == 0:
        print(i)
        break

    num = (num * 10 + 7) % k

Submission status: Wrong Answer

Solution code:
k = int(input())

def f(k):
    sevens=0
    for i in range(1, k):
        sevens = (sevens*10+7) % k
        if sevens == 0:
            return i
    return -1

print(f(k))

Submission status: Wrong Answer

Solution code:
k = int(input())
if(k%2==0 or k%5==0):
    print(-1)
    exit()
else:
    i=1
    seven=7%k
    while seven!=0:
        seven = (seven*10+7)%k
        print(seven)
        i+=1
    print(i)

Submission status: Wrong Answer

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

K = INT()

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

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

Submission status: Wrong Answer

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

K = INT()

checked = [0]*K

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

Submission status: Wrong Answer

Solution code:
k = int(input())

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

for i in range(1, k):
    if num % k == 0:
        print(i)
        exit(0)

    num = (num * 10 + 7) % k

Submission status: Wrong Answer

Solution code:
K = int(input())

X = 10
ans = 1

while ans <= 100000000:
    x = X%(9*K)
    if x == 1:
        print(ans)
        break
    else:
        ans += 1
        X = x*10 

if x != 1:
    print(-1)

Submission status: Wrong Answer

Solution code:
k = int(input())
k_ = 9*k

mod = (10**(len(str(k_))))%k_
cnt=len(str(k_))
while True:
  if mod % k_==1:
    break
  else:
    mod = (mod*10)%k_
    cnt+=1
print(cnt)

Submission status: Wrong Answer

Solution code:
import math
k = int(input())
count = 1
seven = 7
if k%2 == 0 or k%5 == 0:
    print(-1)
else:
    while True:
        if(seven%k==0):
            print(count)
            break
        else:
            seven += 7* (10**count)
            print (count)
            count+=1

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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

ans = 1
num = 10
while True:
    if num % k == 1:
        break
    num = (num % k) * 10
    ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

K = INT()

checked = [0]*K

a = 0
for i in range(1, K):
	a += 7*pow(10, i-1, K)%K
	a %= K
	if a == 0:
		print(i)
		break
	elif checked[a]:
		print(-1)
		break
else:
	print(-1)

Submission status: Wrong Answer

Solution code:
K = int(input())

X = 10
ans = 1

while ans <= K:
    x = X%(9*K)
    if x == 1:
        print(ans)
        break
    else:
        ans += 1
        X = x*10 

if x != 1:
    print(-1)

Submission status: Wrong Answer

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

K = INT()

checked = [0]*K

a = 0
for i in range(1, K):
	a += 7*pow(10, i-1, K)
	a %= K
	if a == 0:
		print(i)
		break
	elif checked[a]:
		print(-1)
		break

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from __future__ import print_function

import sys
sys.setrecursionlimit(500000)

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction

import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return

# from fractions import gcd
# from math import gcd

# def lcm(n, m):
#     return int(n * m / gcd(n, m))


# def coprimize(p, q):
#     common = gcd(p, q)
#     return (p // common, q // common)


# def find_gcd(list_l):
#     x = reduce(gcd, list_l)
#     return x


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


mod=1000000007
def combinations_count_mod(n, r):
    r = min(r, n - r)
    numer = reduce(lambda x,y: x*y%mod, range(n, n - r, -1), 1)
    denom = pow( reduce(lambda x,y: x*y%mod, range(1, r + 1), 1) , mod-2, mod)
    return numer * denom % mod



def main():
    k = int(input().strip())
    if k%2==0:
        print(-1)
    else:
        temp=0
        for i in range(10**6):
            temp+=(7*(10**i)) % k
            temp=temp%k
            eprint('i, temp ',end=':\n')
            eprint(i, temp)
            if temp==0:
                print(i+1)
                return
    print(-1)



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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**4):
    if num % K == 0:
        print(i+1)
        sys.exit()
    else:
        num += 7*10**(i+1)
print(-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

cnt = 0
if k % 2 == 1 and not k % 5 == 0:
    while(1):
        if s == 0:
            cnt += 1
            print(cnt)
            break
        else:
            s = (s * 10 + 7) % k
            cnt += 1

Submission status: Wrong Answer

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

cnt = 0
if k % 2 == 1 and not k % 5 == 0:
    while(1):
        if s == 0:
            cnt += 1
            print(cnt)
            break
        else:
            s = (s * 10 + 7) % k
            cnt += 1
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
k = int(input())


i = 0;
mod = 0;
while True:
    mod = (mod*10 + 7) % k;
    print(mod)
    if mod == 0:
        break;
    i += 1;
    if i == k:
        i = -2
        break;

print(i+1)

Submission status: Wrong Answer

Solution code:
def main():
    K = int(input())
    Kstr = str(K)
    
    if Kstr[-1] in ('0','2','4','6','8','5'):
        print(-1)
    else:
        if K%7 == 0:
            L = (9*K)/7
        else:
            L = 9*K
        S = 10
        for i in range(1,K):
            S = S%L
            if S == 1:
                print(i)
                break
            S = S*10
    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
k = int(input())


i = 0;
mod = 0;
while True:
    mod = (mod*10 + 7) % k;
    if mod == 0:
        break;
    i += 1;
    if i == k:
        j = -2
        break;

print(i+1)

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    k = int(input())

    if k % 2 == 0 or k % 2 == 5:
        print('-1')
    else:
        mod_list = [7 % k]
        if mod_list[-1] == 0:
            print(1)
        else:
            for i in range(1000000):
                mod_list.append((mod_list[0] + mod_list[-1] * 10) % k)
                if mod_list[-1] == 0:
                    break
            print(len(mod_list))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
param_k = int(input())

for i in range(100):
    param_str = '7'*(i+1)
    param_int = int(param_str)
    
    if param_int % param_k == 0:
        param_answer = i+1
        break

try:
    print(param_answer)
except:
    print(-1)

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    k = int(input())

    if k % 2 == 0 or k % 2 == 5:
        print('-1')
    else:
        mod_list = [7 % k]
        for i in range(1000000):
            mod_list.append((mod_list[0] + mod_list[-1] * 10) % k)
            if mod_list[-1] == 0:
                break
        print(len(mod_list))

Submission status: Wrong Answer

Solution code:
def main():
    import sys
    
    input = sys.stdin.readline
 
    K = int(input())
    res = 7
 
    if K % 2:
        while res < 10 ** 8:
            cal = K * res
            k = str(cal)
            if k.count('7') == len(k):
                print(len(k))
                break
            res += 7
        else:
            print('-1')
    else:
        print('-1')
 
 
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    import sys
    
    input = sys.stdin.readline
 
    K = int(input())
    res = 7
 
    if K % 2:
        while res < 10 ** 7:
            cal = K * res
            k = str(cal)
            if k.count('7') == len(k):
                print(len(k))
                break
            res += 7
        else:
            print('-1')
    else:
        print('-1')
 
 
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:

K=int(input())
num=len(str(K))
start=7
count=0
last=int(str(K)[-1])
li=[1,3,7,9]

if last not in li:
    print(-1)
    exit()
else:
    while(True):
        if start%K==0:
            break
        else:
            start=start*10+7
            count+=1
print(count)

Submission status: Wrong Answer

Solution code:
import sys
k = int(sys.stdin.read())
k *= 9
limit = 1000000
value = 0
index = 0
while index < limit:
  index += 1
  value = (value*10+7)%k
  if value == 0:
    print(index)
    sys.exit()

print(-1)

Submission status: Wrong Answer

Solution code:
K = int(input())

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

Submission status: Wrong Answer

Solution code:
K = int(input())

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

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

Submission status: Wrong Answer

Solution code:
k = int(input())
if k == 7:
  print(1)
else:
  ans=val=n=1
  fin = -1
  se = set()
  while ans not in se:
    se.add(ans)
    val *= 10
    val %= k
    ans += val
    ans %= k
    n += 1
    if not ans:
      fin = n
      break
  print(fin)

Submission status: Wrong Answer

Solution code:
k = int(input())
x = 7
ans = 1
flag = [False]*k
while x != 0:
    ans += 1
    x = (x*10%k+7)%k
    if flag[x]:
        ans = -1
        break
    flag[x] = True
print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    K = int(input())
    if K%10:
        L = 9*K if K%7 else 9*K//7
        mod = 10%L
        for i in range(9000001):
            if mod == 1:
                print(i)
                exit()
            mod = 10*mod%L
    else:
        print(-1)
    

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    k = int(input().strip())
    x = 7 % k
    ans = -1
    for n in range(1, k):
        if x == 0:
            ans = n
            break
        x = (10 * x + 7) % k

    print(ans)
    return


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

cnt = 0
if k % 2 == 1:
    while(1):
        if s == 0:
            cnt += 1
            print(cnt)
            break
        else:
            s = (s * 10 + 7) % k
            cnt += 1
else:
    print(-1)

Submission status: Wrong Answer

Solution code:

def solve(K):
    a = 7 % K
    for i in range(1, K+1):
        a = (a * 10 + 7) % K
        if a == 0:
            return i+1
    return -1 

        

def solve0(K):
    a = 7
    for i in range(0, 10000):
        if a % K == 0:
            return i
        a = a*10+7
    return -1

K = int(input())
print(solve(K))

Submission status: Wrong Answer

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

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

    n = 0
    i = 1
    while True:
        n %= k
        n = 10*n * 7
        if n % k == 0:
            print(i)
            return
        if k < i:
            print(-1)
            return
        i += 1

main()

Submission status: Wrong Answer

Solution code:
K=int(input())
if K%2==0 or K%5==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

Submission status: Wrong Answer

Solution code:
def main():
    k = int(input().strip())
    if k % 2 == 0 or k % 5 == 0:
        print(-1)
        return
    x = 7 % k
    for n in range(1, k):
        if x == 0:
            print(n)
            return
        x = (10 * x + 7) % k

    print(-1)
    return


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
#-*-coding:utf-8-*-
 
import sys
 
def main():
    k = int(input())
    sevens=0
    if k%2==0:
      print(-1)
      exit()
    for i in range(1,k+1):
        sevens=(sevens*10+7)%k
        if sevens==0:
            print(i)
            exit()
 
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
k = int(input())

if k%2==0 or k%5==0:
    print('-1') 
else:
    a = 0
    for i in range(99983):
        a = (a*10+7) % k
        if a == 0:
            print(i+1)
            break
    else:
        print(-1)