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:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy
import bisect

INF = 10**9+7

if __name__ == "__main__":
    k = int(input())
    if k%2 == 0:
        print(-1)
        sys.exit()
    cnt = 1
    a = 7
    while a<10**10000+1:
        if a%k == 0:
            print(cnt)
            sys.exit()
        a*=10
        a+=7
        cnt+=1
    print(k-1)

Submission status: Wrong Answer

Solution code:
K=int(input())
if K==7:
    print(1)
elif K==11 or K==77:
    print(2)
elif K==3 or K==37 or K==111:
    print(3)
elif K==101 or K==1111:
    print(4)
elif K==41 or K==271 or K==11111:
    print(5)
elif K==49 or K==13 or K==21 or K==3*49 or K==33 or K==39 or K==3*37 or K==7*13 or K==7*37 or K==49*11 or K==49*13 or K==49*37 or K==11*13 or K==11*37 or K==13*37:
    print(6)
else:
    print("-1")

Submission status: Wrong Answer

Solution code:
K = int(input())
 
i = 0
t = 7
 

while True:
  if K % t == 0: 
    print(i)
    break
  elif t > 10**6:
    print(-1)
    break
 
  i += 1  
  t += 7 * 10**i

Submission status: Wrong Answer

Solution code:
K = int(input())

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
K = int(input())

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

for i in range(1,K**2):
    if 7*(pow(10,i,K)-1)/9%K==0:
        print(i)
        exit()

print(-1)

Submission status: Wrong Answer

Solution code:
def main():

    K = int(input())
    # N, D = map(int, input().split())
    # A = [int(i) for i in input().split()]
    M = 10 ** 9
    S = [str(i) for i in range(2, 9)]

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

    for i in range(3, int(K ** 0.5) + 2, 2):
        if K % i == 0:
            break
    else:
        for i in str(K):
            if i in S:
                print(K - 1)
                exit()



    N = 7
    for i in range(1, 10 ** 12):
        # print(f"{N = }")
        N %= K
        if not N:
            break
        elif K < i:
            i = K - 1
            break
        N = N * 10 + 7

    print(i)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
input = lambda:sys.stdin.readline().rstrip()

K = int(input())
ans = 0
if K == 7:
    print(1)
    exit()
for i in range(10**7):
    ans += pow(10,i,K)
    if ans % K == 0:
        print(i+1)
        exit()
print(-1)

Submission status: Wrong Answer

Solution code:
K=int(input())


if K%2==0 or K%5==0:
    print(-1)
    exit()
elif K==7:
    print(1)
else:
    M=7%K
    B=7%K
    for i in range(10**7):
        A=((B*10)%K)
        M+=A
        M%=K
        if M==0:
            print(i+2)
            exit()
        B=A+0
        #print(M,B,i)

Submission status: Wrong Answer

Solution code:
k=int(input())
keta=str(k)
s=int("7"*len(keta))
a=-1
if k%2==0:
	print(a)
else:
	for x in range(len(keta),len(keta)+1000):
		print(s)
		if s%k==0:
			a=x
			break
		else:
			s=str(s)+"7"
			s=int(s)
	if a==-1:
		a=k-1
	print(a)

Submission status: Wrong Answer

Solution code:
K=int(input())
if K%2==0 or K%5==0:
	print("-1")
	exit()
for n in range(1,10**4+1):
	if (7*(10**n-1)//9)%K==0:
		print(n)
		exit()
else:
	print(K-1)

Submission status: Wrong Answer

Solution code:
import numpy as np
k = int(input())

if k % 2 ==0:
  print(-1)
elif str(k)[0] == 5:
  print(-1)
elif k  == 101:
  print(4)
else:
  print(k-1)

Submission status: Wrong Answer

Solution code:
def main():
    k = int(input())
    counter = len(str(k * 7))

    while True:
        if k % 2 == 0:
            print(-1)
            return 
        counter += 1
        temp7 = ''.join((["7"] * counter))
        if int(temp7) % k == 0:
            print(len(temp7))
            return 

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
K = int(input())

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

else:
  i = 0
  tmp_n = 0
  while i >= 0:
    tmp_n = tmp_n + 10**i * 7

    print('tmp_n: ', tmp_n)
    if K <= tmp_n:
      if tmp_n != 0 and tmp_n % K == 0:
        break
    i += 1
    
  print(i+1)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import itertools
import random
from collections import deque
from decimal import *
import queue
from functools import reduce

input = sys.stdin.readline

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

def main():
	K = inputInt()

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

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

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

	print(-1)


#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
if __name__ == "__main__":
	main()

Submission status: Wrong Answer

Solution code:
X = int(input())


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


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

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

Submission status: Wrong Answer

Solution code:
import math

K = int(input())
sevn = 7
while True:
    if K < 7:
        print(-1)
        break
    f, i = math.modf(sevn / K)

    if f == 0.0:
        print(len(str(sevn)))
        break
    sevn = str(sevn) + '7'
    sevn = int(sevn)
    print(sevn)

Submission status: Wrong Answer

Solution code:
s=0
l=[]
k=int(input())
while(1):
  s=s*10+7
  l.append(s)
  if s%k==0:
    print(l.index(s))
    break

Submission status: Wrong Answer

Solution code:
k = int(input())
ans = 0
count = 1

if k%2 == 0 or k %5 == 0 :
    print(-1)
else :
    s = 7
    while ans == 0 :
        if s%k == 0 :
            ans = count
        else :
            s += 7*(10**count) % k
            s %= k
            count += 1
            print(s,count)
    print(ans)

Submission status: Wrong Answer

Solution code:
divisor = []

ans1 = [7]
ans2 = [11, 11*7]
ans3 = [3, 37, 3*7, 3*37, 37*7, 3*37*7]
ans4 = [101, 101*7, 11*101, 11*101*7]
ans5 = [41, 271, 41*7, 271*7, 41*271, 41*271*7]
ans6 = []
ans7 = [239, 239*7, 4649, 4649*7]

ans6_divisor = [3, 7, 7, 11, 13, 37]
flag = [0]*6
for i in range(1,2**len(ans6_divisor)):
    for j in reversed(range(len(ans6_divisor))):
        flag[j] = i // 2**j
        i -= flag[j] * 2**j
    tmp = 1
    for f in range(len(flag)):
        if flag[f] != 0:
            tmp *= flag[f]*ans6_divisor[f]
    ans6.append(tmp)


Ans = [ans1, ans2, ans3, ans4, ans5, ans6, ans7]
for ans in Ans:
    divisor.extend(ans)

K = int(input())
if K not in divisor:
    print(-1)
else:
    for i, ans in enumerate(Ans):
        if K in ans:
            print(i+1)
            break

Submission status: Wrong Answer

Solution code:
N = int(input())
li = [0,2,4,5,6,8]
if N % 10 in li:
    print(-1)
else:
    count = 1
    nana = 7
    flag = 0
    for i in range(10000):
        if nana % N == 0:
            flag = 1
            break

        count += 1
        nana *= 10
        nana += 7
    if flag == 1:
        print(count)
    else:
        print(N-1)

Submission status: Wrong Answer

Solution code:
import numpy as np
k = int(input())

if k % 2 ==0:
  print(-1)
elif str(k)[0] == 5:
  print(-1)
else:
  print(4)

Submission status: Wrong Answer

Solution code:
K=49

def solve(K):
    f=0
    from collections import defaultdict
    if K==1:
        return 1
    elif K%2==0 or K%5==0:
        return -1
    
    if K%7==0:
        if K==7:
            return 1
        else:
            f=1
            K=K//7

    app = defaultdict(lambda: False)
    broken=False
    for n in range(1,K+1):
        if n==1:
            if f==1:
                amari = 1
            else:
                amari = 7%K
        else:
            if f==1:
                amari = (amari + pow(10,n-1,K) )%K
            else:
                amari = (amari + 7*pow(10,n-1,K) )%K
        #print(n,amari)
        if amari==0:
            broken=True
            break
        if app[amari]:
            broken=True
            break
        else:
            app[amari]=True
    if broken:
        return n
    else:
        return -1
    

print(solve(K))

Submission status: Wrong Answer

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

import sys
import numpy as np
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)


def isMultiple(s, m):
    tmp = 0
    for i in range(len(s)):
        tmp = (tmp * 10 + int(s[i])) % m
        if tmp == 0:
            return i
    return -1


k = int(readline())
acc = "7" * 1000000
if k % 2 == 0:
    ans = -1
else:

    ans = isMultiple(acc, k) + 1

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
K = int(input())
for i in range(1, K+1):
    x = K * i
    s = list(str(x))
    if s.count('7') == len(s):
        print(len(s))
        exit()
print(-1)

Submission status: Wrong Answer

Solution code:
from sys import stdin,stdout
def INPUT():return list(int(i) for i in stdin.readline().split())
import math
def inp():return stdin.readline()
def out(x):return stdout.write(x)
import math as M
MOD=10**9+7
import random
#####################################
k=int(input())
A=[1]*(10**6+1)
for i in range(1,10**6+1):
    A[i]=(A[i-1]*10)%k
ind=1
sum=1
while(sum!=0 and ind<=10**6):
    if (A[ind]+sum)%k==0:
        ans=ind
        break
    sum=(sum+A[ind])%k
    ind+=1
if k==1 or k==7:
    print(1)
elif ind==10**6+1:
    print(-1)
else:
    print(ans+1)

Submission status: Wrong Answer

Solution code:
k = int(input())

flag = True

for i in range(k, 10**6):
  if str(i).count("7") == len(str(i)) and i%k == 0:
    x = i
    print(len(str(i)))
    flag = False
    break
if flag:
  print(-1)

Submission status: Wrong Answer

Solution code:
K=int(input())
count=0
n=7
if n%K==0:
    print('1')

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

Submission status: Wrong Answer

Solution code:
s = '7'
n = int(input())
if n % 2 == 0 or n % 5 == 0:
    print(-1)
    exit()

if n < 17 or n % 3 == 0 or n % 7 == 0:
    for i in range(10**6):
        if int(s) % n == 0:
            print(len(s))
            exit()
        s += '7'
else:
    print(n-1)

Submission status: Wrong Answer

Solution code:

k = int(input())
count=1
x=7
#for i in range(1,10):
    #print(x)
while True:
    x+=7*(10**count)
    if k%2==0:
        break
    
    if x>k and x%k==0:
        print(count+1)
        break
    count+=1
if count==1:
    print(-1)

Submission status: Wrong Answer

Solution code:

#!/usr/bin/python
# -*- coding: utf-8 -*-

# def
def int_mtx(N):
    x = []
    for _ in range(N):
        x.append(list(input()))
    return x

def int_map():
    return map(int,input().split())

def int_list():
    return list(map(int,input().split()))

def print_space(l):
    return print(" ".join([str(x) for x in l]))

# import
import numpy as np



# main code
K = int(input())

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


y = 7%K
x = 7%K

for i in range(1,K+1):
    x = (10*x)%K
    y = (y+x)%K
    if y == 0:
        print(i+1)
        exit()

print(-1)

Submission status: Wrong Answer

Solution code:
K = int(input())
for i in range(1, K):
    if K % 2 == 0:
        print('-1')
        break
    elif int('7'*(i)) % K == 0:
        print(i)
        break

Submission status: Wrong Answer

Solution code:
K = int(input())

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

repunit = 7
for i in range(2, K):
    repunit = (repunit*10 + 7)%K
    if repunit == 0:
        print(i)
        exit()
print(K-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
K = int(input())

i = 0
t = 7

try:
  while True:
    if K % t == 0: 
      print(i)
      break

    i += 1  
    t += 7 * 10**i
except:
  print(-1)

Submission status: Wrong Answer

Solution code:
K = int(input())

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

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

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 = (10 * A + 7) % K
    if A == 0:
        print(i+1)
        break

Submission status: Wrong Answer

Solution code:
s = int(input()) 
 
L=[7,
77,
777,
7777,
77777,
777777,
7777777,
77777777,
777777777,
7777777777,
77777777777,
777777777777,
7777777777777,
77777777777777,
777777777777777,
7777777777777777,
77777777777777777,
777777777777777777,
7777777777777777777,
77777777777777777777,
777777777777777777777,
7777777777777777777777,
77777777777777777777777,
777777777777777777777777,
7777777777777777777777777,
77777777777777777777777777,
777777777777777777777777777,
7777777777777777777777777777,
77777777777777777777777777777,
777777777777777777777777777777,
7777777777777777777777777777777,
77777777777777777777777777777777,
777777777777777777777777777777777,
7777777777777777777777777777777777,
77777777777777777777777777777777777]
 
ans=0
for i,a in enumerate(L):
    if a % s==0:
        ans=i+1
        break
    
else :
    ans=-1
print(ans)

Submission status: Wrong Answer

Solution code:
import math

K = 101#input()
sevn = 7
while True:
    
    f, i = math.modf(sevn / K)

    if f == 0.0:
        print(len(str(sevn)))
        break
    sevn = str(sevn) + '7'
    sevn = int(sevn)
    print(sevn)

Submission status: Wrong Answer

Solution code:
K = int(input())

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

a = 0
if K < 900000:
  for i in range(K):
    a = 7 * 10**(i) + a
    if a % K == 0:
      print(i)
      break
elif K >= 900000:
  print(999982)

Submission status: Wrong Answer

Solution code:
k=int(input())


def get(k):
    if k%7==0:
        k=k//7
    ans=1
    for i in range(1,k):
        if ans%k==0:
            return i
        ans=(ans*10+1)%k
    else:
        return 0





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

else:
    print(get(k))

Submission status: Wrong Answer

Solution code:
a=int(input())
l=[7, 77, 777, 7777, 77777, 777777, 7777777]
text=0
for i in l:
  
  if i%a==0:
    text=str(l.index(i)+1)
    break
  else:
    text = "-1"
print(text)

Submission status: Wrong Answer

Solution code:

import sys

a = [2,4,5,6,8,0]
N = input()

Q = len(N) * "7"

print(Q)

if int(N[-1]) in a :
    print(-1)
    sys.exit()
    
N = int(N)

K = "7"

for i in range(20000):
    S = int(K)
    if S % N == 0:
        print(len(K))
        sys.exit()
    K = K + Q
# print(len(K))
print(-1)

Submission status: Wrong Answer

Solution code:
k = int(input())
if k%2==0 or k%5==0:
    print(-1)
    exit()
    
def so(n):
  for i in range(2,int(n**0.5)+1):
    if n%i==0:
      return False
  else:
    return True
    
t = 50000
if k%7==0:
  k//= 7
l = len(str(k))
s = int(str(1)*l)
ind = l
while t!=0 :
    if s%k==0:
        print(ind)
        exit()
    else:
        s = s*10+1
        ind += 1
    t -=1
if so(k)==True:
  print(k-1)
  exit()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

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

for i in range(1000000):
    K_prime = prime_factorize(K)
    seven_prime = prime_factorize(seven)
    if set(K_prime) <= set(seven_prime):
        print(cnt)
        exit(0)
    seven += plus*10**i
    cnt += 1

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
X = int(input())


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


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

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

Submission status: Wrong Answer

Solution code:
def resolve():
    k = int(input())
    if k % 2 == 0:
        print(-1)
        return
    for i in range(1, 10 ** 6):
        if (7 * pow(10, i, k)) % k == 7 % k:
            print(i)
            return
    print(-1)


if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy
import bisect

INF = 10**9+7

if __name__ == "__main__":
    k = int(input())
    if k%2 == 0:
        print(-1)
        sys.exit()
    a = 7
    p = len(str(k)) + 1
    for i in range(p+10**3):
        if a%k == 0:
            print(i+1)
            sys.exit()
        a*=10
        a+=7
    print(k-1)

Submission status: Wrong Answer

Solution code:
s = int(input()) 
 
L=[7,
77,
777,
7777,
77777,
777777,
7777777,
77777777,
777777777,
7777777777,
77777777777,
777777777777,
7777777777777,
77777777777777,
777777777777777,
7777777777777777,
77777777777777777,
777777777777777777,
7777777777777777777,
77777777777777777777,
777777777777777777777,
7777777777777777777777,
77777777777777777777777,
777777777777777777777777,
7777777777777777777777777,
77777777777777777777777777,
777777777777777777777777777,
7777777777777777777777777777]
 
ans=0
for i,a in enumerate(L):
    if a % s==0:
        ans=i+1
        break
    
else :
    ans=-1
print(ans)

Submission status: Wrong Answer

Solution code:
import math
K = int(input())
seven = int("7" * int(math.log10(K) + 1))
count = 1
while True:
    if seven % K == 0:
        print(count)
        break
    count += 1
    seven = seven * 10 + 7

Submission status: Wrong Answer

Solution code:
K = input()
digit = len(K)
K = int(K)
divided = ((10**(digit) - 1)*7) / 9
flag = True
remains = []
while flag:
  remain = divided%K
  if remain==0:
    flag = False
    print(digit)
  elif remain in remains:
    flag = False
    print(-1)
  else:
    remains.append(remain)
    digit += 1
    divided = divided*10 + 7

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline

k = int(input())
if k % 2 == 0 or k % 5 == 0: print(-1)
else:
    mod = 9*k
    i = 1;
    result = 10;
    while result != 1:
        result = (result * 10) % mod
        i += 1
    print(i)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(500000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

k=int(input())

if k%2==0 or k%5==0:
    print(-1)
else:
    # if k%7==0:
    #     k//=7
    tmp=1
    cnt=1
    while (7*(tmp*10-1))%k:
        tmp*=10
        tmp%=k
        cnt+=1
    print(cnt)

Submission status: Wrong Answer

Solution code:
K=int(input())

def solve(K):
    from collections import defaultdict
    if K==1:
        return 1
    elif K%2==0 or K%5==0:
        return -1
    
    elif K%7==0:
        K=K//7
        app = defaultdict(lambda: False)
        broken=False
        for n in range(1,K+1):
            if n==1:
                amari = 1
            else:
                amari = (amari + pow(10,n-1,K) )%K
                
            if amari==0:
                broken=True
                break
            if app[amari]:
                broken=True
                break
            else:
                app[amari]=True
            
        if broken:
            return n
        else:
            return -1
        
        
    else:        
        app = defaultdict(lambda: False)
        broken=False
        for n in range(1,K+1):
            if n==1:
                amari = 7%K
            else:
                amari = (amari + 7*pow(10,n-1,K) )%K
            #print(n,amari)
            if amari==0:
                broken=True
                break
            if app[amari]:
                broken=True
                break
            else:
                app[amari]=True
        if broken:
            return n
        else:
            return -1
        

print(solve(K))

Submission status: Wrong Answer

Solution code:
##a = int(stdin.readline().rstrip())
##b, c = [int(x) for x in stdin.readline().rstrip().split()]
##s = stdin.readline().rstrip()
##a = list(set(b))  重複を削除
##a = list(map(int,[int(x) for x in stdin.readline().rstrip().split()])) a[0, 1, 2, ...]
##a = [[0] * 2 for _ in range(n)]  a[0,0]
##v = [s[i: i+2] for i in range(0, len(s), 2)]
##  s="12345678" を v=["12","34","56","78"] にするイメージ
##s = "".join(list)リストを文字列に変換[""]は区切り文字
##a.sort(key=itemgetter(1))リストをソートできるよ(from operator import itemgetterが必要)
##sort_p = sorted(p) 昇順ソート

# -*- coding: utf-8 -*-
from sys import stdin
from operator import itemgetter
from collections import deque, Counter
import math
import pprint
from functools import reduce
import numpy as np
import random
import bisect
import copy
# stdin = open("sample.txt")


MOD = 1000000007
INF = float('inf')
alpha = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]

def keta(kazu): # 入力されたintを桁ごとに分解，リストで出力
    kazu_str = str(kazu)
    kazu_list = [int(kazu_str[i]) for i in range(0, len(kazu_str))]
    return kazu_list

def gcd(*numbers): # 最小公倍数
    return reduce(math.gcd, numbers)

def combination(m,n): # mCn
    
    if n > m:
        return 'すまん'
    return math.factorial(m) // (math.factorial(m-n) * math.factorial(n))

def pow_k(x,n):  # (x**n)の計算の高速化
    if n == 0:
        return 1
    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x
        x *= x
        n //= 2
    return K * x

def fact(n): # nの素因数分解の結果を辞書で出力 fuct(24) → {2: 3, 3: 1}
    arr = {}
    temp = n
    for i in range(2,int(n**0.5)+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr[i] = cnt
    if temp != 1:
        arr[temp] = 1
    if arr == {}:
        arr[n] = 1
    return arr
    
def main():
    K = int(stdin.readline().rstrip())
    if K % 2 == 0 or K % 5 == 0:
        print("-1")
    else:
        for n in range(1,1000000):
            an = (10*(10**(n-1))-1)//9
            if an % K == 0:
                print(n)
                break
        if n == 1000000:
            print("-1")
        
    
main()

Submission status: Wrong Answer

Solution code:
K = int(input())

#偶数は弾く
if K % 2 == 0:
    print(-1)

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

Submission status: Wrong Answer

Solution code:
k=int(input())
if k%2 == 0 or k%5 == 0:
  print(-1)
  exit()
s = ''
for i in range(10000):
  s += '7'
  if int(s) % k == 0:
    print(i+1)
    exit()
#nの素数判定
def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True
if k%7 == 0:
  k//=7
if is_prime(k):
  print(k-1)
  exit()
print(-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#from math import *
from collections import *
from random import *
from bisect import *
import sys
input=sys.stdin.readline
def lis():
    return list(map(int,input().split()))
def ma():
    return map(int,input().split())
def inp():
    return int(input())
n=inp()
if(n%2==0 or n%5==0):
    print(-1)
    exit(0)
co=1
if(7%n==0):
    print(1)
    exit(0)
while(1):
    gp=10*(pow(10,co,n)-1)
    gp=gp%n
    gp=gp*pow(9,n-2,n)
    gp+=1
    gp=7*gp
    gp=gp%n
    if(co>2000000):
        co=-2
        break
    if(gp%n==0):
        break
    co+=1
print(co+1)

Submission status: Wrong Answer

Solution code:
K = int(input())
k = str(K)
num = -1

if K % 2 == 0:
    print("-1")
else:
    while True:
        num += 1
        zoro = [7] * (len(k)+num)
        zorome = int(''.join(map(str, zoro)))
        print(num)

        if zorome % K ==0:
            print(len(k)+num)
            break

Submission status: Wrong Answer

Solution code:
k = int(input())

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

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

Submission status: Wrong Answer

Solution code:

k=int(input())
j=1
s=7

if k<7 or k%2==0:
    print(-1)
else:
    for i in range(10**12):
        if s%k==0:
            print(j)
            break
        s=s*10+7
        j+=1

Submission status: Wrong Answer

Solution code:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy
import bisect

INF = 10**9+7

if __name__ == "__main__":
    k = int(input())
    if k%2 == 0:
        print(-1)
        sys.exit()
    a = 7
    p = len(str(k)) + 1
    for i in range(p+100):
        if a%k == 0:
            print(i+1)
            sys.exit()
        a*=10
        a+=7
    print(k-1)

Submission status: Wrong Answer

Solution code:
k=int(input())
if k%2 == 0 or k%5 == 0:
  print(-1)
  exit()
s = ''
for i in range(100):
  s += '7'
  if int(s) % k == 0:
    print(i+1)
    exit()
#nの素数判定
def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True
if k%7 == 0:
  k//=7
if is_prime(k):
  print(k-1)
  exit()
print(-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
k = int(input())
f = False

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

else:
  n = 0
  for j in range(1000000000):
    n += (10 ** j) * 7
    if n % k == 0:
      print(n)
      break

Submission status: Wrong Answer

Solution code:
K = int(input())

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

i = 1
last_i = 10 ** 6
while True:
    if (i == last_i):
        print(-1)
        exit()
    an = (7 * ((10 ** i) - 1))
    an_last = (7 * ((10 ** last_i) - 1))
    if (an % K == 0):
        print(i)
        exit()
    elif (an_last % K == 0):
        print(last_i)
        exit()
    else:
        i += 1
        last_i -= 1
        continue

Submission status: Wrong Answer

Solution code:
K = int(input())

A = 7
anum = 1
ans = 1

while A // K <= 10**6:
  if K % 2 == 0 or K % 5 == 0:
    print('-1')
    break
  if A % K == 0:
    print(ans)
    break
  A = A * 10 + 7
  ans = ans + 1
if A // K >= 10**6:
  print('-1')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a = int(input())
s = 0
i=round(a/10)
if a % 2 == 0:
    print(-1)
    quit()
while True:
    s = s + (10**i) * 7
    if s % a == 0:
        print(i+1)
        break
    i += 1

Submission status: Wrong Answer

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

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