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:
# Hey, there Stalker!!!
# This Code was written by:
# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
# ▒▒╔╗╔═══╦═══╗▒▒▒╔╗▒▒▒
# ▒╔╝║║╔═╗║╔═╗╠╗▒▒║║▒▒▒
# ▒╚╗║║║║║║║║║╠╬══╣║╔╗▒
# ▒▒║║║║║║║║║║╠╣║═╣╚╝╝▒
# ▒╔╝╚╣╚═╝║╚═╝║║║═╣╔╗╗▒
# ▒╚══╩═══╩═══╣╠══╩╝╚╝▒
# ▒▒▒▒▒▒▒▒▒▒▒╔╝║▒▒▒▒▒▒▒
# ▒▒▒▒▒▒▒▒▒▒▒╚═╝▒▒▒▒▒▒▒
# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
#from functools import reduce

#mod=int(1e9+7)
#import resource
#resource.setrlimit(resource.RLIMIT_STACK, [0x100000000, resource.RLIM_INFINITY])
#import threading
#threading.stack_size(2**26)
"""fact=[1]
#for i in range(1,100001):
#    fact.append((fact[-1]*i)%mod)
#ifact=[0]*100001
#ifact[100000]=pow(fact[100000],mod-2,mod)
#for i in range(100000,0,-1):
#    ifact[i-1]=(i*ifact[i])%mod"""
#from collections import deque, defaultdict, Counter, OrderedDict
#from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
#from heapq import heappush, heappop, heapify, nlargest, nsmallest


# sys.setrecursionlimit(10**6) 
from sys import stdin, stdout
import bisect            #c++ upperbound
from bisect import bisect_left as bl              #c++ lowerbound bl(array,element)
from bisect import bisect_right as br             #c++ upperbound
import itertools
from collections import Counter

import collections
import math
import heapq
import re
def modinv(n,p):
    return pow(n,p-2,p)
def cin():
    return map(int,sin().split())
def ain():                           #takes array as input
    return list(map(int,sin().split()))
def sin():
    return input()
def inin():
    return int(input())
  
def Divisors(n) : 
    l = []  
    for i in range(1, int(math.sqrt(n) + 1)) :
        if (n % i == 0) : 
            if (n // i == i) : 
                l.append(i) 
            else : 
                l.append(i)
                l.append(n//i)
    return l

def most_frequent(list):
    return max(set(list), key = list.count) 
def GCD(x,y):
    while(y):
        x, y = y, x % y
    return x

def ncr(n,r,p):                                              #To use this, Uncomment 19-25 
    t=((fact[n])*((ifact[r]*ifact[n-r])%p))%p
    return t

def Convert(string): 
    li = list(string.split("")) 
    return li 

def SieveOfEratosthenes(n): 
    global prime
    prime = [True for i in range(n+1)] 
    p = 2
    while (p * p <= n): 
        if (prime[p] == True): 
            for i in range(p * p, n+1, p): 
                prime[i] = False
        p += 1
    f=[]
    for p in range(2, n): 
        if prime[p]: 
            f.append(p)
    return f
prime=[]
q=[]
def dfs(n,d,v,c):
    global q
    v[n]=1
    x=d[n]
    q.append(n)
    j=c
    for i in x:
        if i not in v:
            f=dfs(i,d,v,c+1)
            j=max(j,f)
            # print(f)
    return j

#Implement heapq
#grades = [110, 25, 38, 49, 20, 95, 33, 87, 80, 90] 
#print(heapq.nlargest(3, grades)) #top 3 largest
#print(heapq.nsmallest(4, grades))
#Always make a variable of predefined function for  ex- fn=len
#n,k=map(int,input().split())
"""*******************************************************"""
def main():
    n=inin()
    if n&1==0:
        print(-1)
    else:
        cnt=1
        temp=0
        z=0
        while cnt<=n:
            #print(cnt,int(cnt*str(7))) 
            z=(10*z+7)%n
            if z==0:
                print(cnt)
                break
            cnt+=1
            


"""*******************************************************"""
######## Python 2 and 3 footer by Pajenegod and c1729
py2 = round(0.5)
if py2:
    from future_builtins import ascii, filter, hex, map, oct, zip
    range = xrange
 
import os, sys
from io import IOBase, BytesIO
 
BUFSIZE = 8192
class FastIO(BytesIO):
    newlines = 0
 
    def __init__(self, file):
        self._file = file
        self._fd = file.fileno()
        self.writable = "x" in file.mode or "w" in file.mode
        self.write = super(FastIO, self).write if self.writable else None
 
    def _fill(self):
        s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
        self.seek((self.tell(), self.seek(0,2), super(FastIO, self).write(s))[0])
        return s
 
    def read(self):
        while self._fill(): pass
        return super(FastIO,self).read()
 
    def readline(self):
        while self.newlines == 0:
            s = self._fill(); self.newlines = s.count(b"\n") + (not s)
        self.newlines -= 1
        return super(FastIO, self).readline()
 
    def flush(self):
        if self.writable:
            os.write(self._fd, self.getvalue())
            self.truncate(0), self.seek(0)
 
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        if py2:
            self.write = self.buffer.write
            self.read = self.buffer.read
            self.readline = self.buffer.readline
        else:
            self.write = lambda s:self.buffer.write(s.encode('ascii'))
            self.read = lambda:self.buffer.read().decode('ascii')
            self.readline = lambda:self.buffer.readline().decode('ascii')
 
 
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip('\r\n')
if __name__== "__main__":
    main()
#threading.Thread(target=main).start()

Submission status: Wrong Answer

Solution code:
# Hey, there Stalker!!!
# This Code was written by:
# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
# ▒▒╔╗╔═══╦═══╗▒▒▒╔╗▒▒▒
# ▒╔╝║║╔═╗║╔═╗╠╗▒▒║║▒▒▒
# ▒╚╗║║║║║║║║║╠╬══╣║╔╗▒
# ▒▒║║║║║║║║║║╠╣║═╣╚╝╝▒
# ▒╔╝╚╣╚═╝║╚═╝║║║═╣╔╗╗▒
# ▒╚══╩═══╩═══╣╠══╩╝╚╝▒
# ▒▒▒▒▒▒▒▒▒▒▒╔╝║▒▒▒▒▒▒▒
# ▒▒▒▒▒▒▒▒▒▒▒╚═╝▒▒▒▒▒▒▒
# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
#from functools import reduce

#mod=int(1e9+7)
#import resource
#resource.setrlimit(resource.RLIMIT_STACK, [0x100000000, resource.RLIM_INFINITY])
#import threading
#threading.stack_size(2**26)
"""fact=[1]
#for i in range(1,100001):
#    fact.append((fact[-1]*i)%mod)
#ifact=[0]*100001
#ifact[100000]=pow(fact[100000],mod-2,mod)
#for i in range(100000,0,-1):
#    ifact[i-1]=(i*ifact[i])%mod"""
#from collections import deque, defaultdict, Counter, OrderedDict
#from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
#from heapq import heappush, heappop, heapify, nlargest, nsmallest


# sys.setrecursionlimit(10**6) 
from sys import stdin, stdout
import bisect            #c++ upperbound
from bisect import bisect_left as bl              #c++ lowerbound bl(array,element)
from bisect import bisect_right as br             #c++ upperbound
import itertools
from collections import Counter

import collections
import math
import heapq
import re
def modinv(n,p):
    return pow(n,p-2,p)
def cin():
    return map(int,sin().split())
def ain():                           #takes array as input
    return list(map(int,sin().split()))
def sin():
    return input()
def inin():
    return int(input())
  
def Divisors(n) : 
    l = []  
    for i in range(1, int(math.sqrt(n) + 1)) :
        if (n % i == 0) : 
            if (n // i == i) : 
                l.append(i) 
            else : 
                l.append(i)
                l.append(n//i)
    return l

def most_frequent(list):
    return max(set(list), key = list.count) 
def GCD(x,y):
    while(y):
        x, y = y, x % y
    return x

def ncr(n,r,p):                                              #To use this, Uncomment 19-25 
    t=((fact[n])*((ifact[r]*ifact[n-r])%p))%p
    return t

def Convert(string): 
    li = list(string.split("")) 
    return li 

def SieveOfEratosthenes(n): 
    global prime
    prime = [True for i in range(n+1)] 
    p = 2
    while (p * p <= n): 
        if (prime[p] == True): 
            for i in range(p * p, n+1, p): 
                prime[i] = False
        p += 1
    f=[]
    for p in range(2, n): 
        if prime[p]: 
            f.append(p)
    return f
prime=[]
q=[]
def dfs(n,d,v,c):
    global q
    v[n]=1
    x=d[n]
    q.append(n)
    j=c
    for i in x:
        if i not in v:
            f=dfs(i,d,v,c+1)
            j=max(j,f)
            # print(f)
    return j

#Implement heapq
#grades = [110, 25, 38, 49, 20, 95, 33, 87, 80, 90] 
#print(heapq.nlargest(3, grades)) #top 3 largest
#print(heapq.nsmallest(4, grades))
#Always make a variable of predefined function for  ex- fn=len
#n,k=map(int,input().split())
"""*******************************************************"""
def main():
    n=inin()
    if n&1==0:
        print(-1)
    else:
        cnt=1
        temp=0
        z=7
        while cnt<=n:
            #print(cnt,int(cnt*str(7))) 
            if z==0:
                print(cnt)
                break
            cnt+=1
            z=(10*z+7)%n


"""*******************************************************"""
######## Python 2 and 3 footer by Pajenegod and c1729
py2 = round(0.5)
if py2:
    from future_builtins import ascii, filter, hex, map, oct, zip
    range = xrange
 
import os, sys
from io import IOBase, BytesIO
 
BUFSIZE = 8192
class FastIO(BytesIO):
    newlines = 0
 
    def __init__(self, file):
        self._file = file
        self._fd = file.fileno()
        self.writable = "x" in file.mode or "w" in file.mode
        self.write = super(FastIO, self).write if self.writable else None
 
    def _fill(self):
        s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
        self.seek((self.tell(), self.seek(0,2), super(FastIO, self).write(s))[0])
        return s
 
    def read(self):
        while self._fill(): pass
        return super(FastIO,self).read()
 
    def readline(self):
        while self.newlines == 0:
            s = self._fill(); self.newlines = s.count(b"\n") + (not s)
        self.newlines -= 1
        return super(FastIO, self).readline()
 
    def flush(self):
        if self.writable:
            os.write(self._fd, self.getvalue())
            self.truncate(0), self.seek(0)
 
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        if py2:
            self.write = self.buffer.write
            self.read = self.buffer.read
            self.readline = self.buffer.readline
        else:
            self.write = lambda s:self.buffer.write(s.encode('ascii'))
            self.read = lambda:self.buffer.read().decode('ascii')
            self.readline = lambda:self.buffer.readline().decode('ascii')
 
 
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip('\r\n')
if __name__== "__main__":
    main()
#threading.Thread(target=main).start()

Submission status: Wrong Answer

Solution code:
# Hey, there Stalker!!!
# This Code was written by:
# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
# ▒▒╔╗╔═══╦═══╗▒▒▒╔╗▒▒▒
# ▒╔╝║║╔═╗║╔═╗╠╗▒▒║║▒▒▒
# ▒╚╗║║║║║║║║║╠╬══╣║╔╗▒
# ▒▒║║║║║║║║║║╠╣║═╣╚╝╝▒
# ▒╔╝╚╣╚═╝║╚═╝║║║═╣╔╗╗▒
# ▒╚══╩═══╩═══╣╠══╩╝╚╝▒
# ▒▒▒▒▒▒▒▒▒▒▒╔╝║▒▒▒▒▒▒▒
# ▒▒▒▒▒▒▒▒▒▒▒╚═╝▒▒▒▒▒▒▒
# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
#from functools import reduce

#mod=int(1e9+7)
#import resource
#resource.setrlimit(resource.RLIMIT_STACK, [0x100000000, resource.RLIM_INFINITY])
#import threading
#threading.stack_size(2**26)
"""fact=[1]
#for i in range(1,100001):
#    fact.append((fact[-1]*i)%mod)
#ifact=[0]*100001
#ifact[100000]=pow(fact[100000],mod-2,mod)
#for i in range(100000,0,-1):
#    ifact[i-1]=(i*ifact[i])%mod"""
#from collections import deque, defaultdict, Counter, OrderedDict
#from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
#from heapq import heappush, heappop, heapify, nlargest, nsmallest


# sys.setrecursionlimit(10**6) 
from sys import stdin, stdout
import bisect            #c++ upperbound
from bisect import bisect_left as bl              #c++ lowerbound bl(array,element)
from bisect import bisect_right as br             #c++ upperbound
import itertools
from collections import Counter

import collections
import math
import heapq
import re
def modinv(n,p):
    return pow(n,p-2,p)
def cin():
    return map(int,sin().split())
def ain():                           #takes array as input
    return list(map(int,sin().split()))
def sin():
    return input()
def inin():
    return int(input())
  
def Divisors(n) : 
    l = []  
    for i in range(1, int(math.sqrt(n) + 1)) :
        if (n % i == 0) : 
            if (n // i == i) : 
                l.append(i) 
            else : 
                l.append(i)
                l.append(n//i)
    return l

def most_frequent(list):
    return max(set(list), key = list.count) 
def GCD(x,y):
    while(y):
        x, y = y, x % y
    return x

def ncr(n,r,p):                                              #To use this, Uncomment 19-25 
    t=((fact[n])*((ifact[r]*ifact[n-r])%p))%p
    return t

def Convert(string): 
    li = list(string.split("")) 
    return li 

def SieveOfEratosthenes(n): 
    global prime
    prime = [True for i in range(n+1)] 
    p = 2
    while (p * p <= n): 
        if (prime[p] == True): 
            for i in range(p * p, n+1, p): 
                prime[i] = False
        p += 1
    f=[]
    for p in range(2, n): 
        if prime[p]: 
            f.append(p)
    return f
prime=[]
q=[]
def dfs(n,d,v,c):
    global q
    v[n]=1
    x=d[n]
    q.append(n)
    j=c
    for i in x:
        if i not in v:
            f=dfs(i,d,v,c+1)
            j=max(j,f)
            # print(f)
    return j

#Implement heapq
#grades = [110, 25, 38, 49, 20, 95, 33, 87, 80, 90] 
#print(heapq.nlargest(3, grades)) #top 3 largest
#print(heapq.nsmallest(4, grades))
#Always make a variable of predefined function for  ex- fn=len
#n,k=map(int,input().split())
"""*******************************************************"""
def main():
    n=inin()
    if n&1==0:
        print(-1)
    else:
        cnt=1
        temp=0
        z=7
        while temp!=1:
            #print(cnt,int(cnt*str(7))) 
            if z==0:
                print(cnt)
                break
            else:
                cnt+=1
            z=(10*z+7)%n


"""*******************************************************"""
######## Python 2 and 3 footer by Pajenegod and c1729
py2 = round(0.5)
if py2:
    from future_builtins import ascii, filter, hex, map, oct, zip
    range = xrange
 
import os, sys
from io import IOBase, BytesIO
 
BUFSIZE = 8192
class FastIO(BytesIO):
    newlines = 0
 
    def __init__(self, file):
        self._file = file
        self._fd = file.fileno()
        self.writable = "x" in file.mode or "w" in file.mode
        self.write = super(FastIO, self).write if self.writable else None
 
    def _fill(self):
        s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
        self.seek((self.tell(), self.seek(0,2), super(FastIO, self).write(s))[0])
        return s
 
    def read(self):
        while self._fill(): pass
        return super(FastIO,self).read()
 
    def readline(self):
        while self.newlines == 0:
            s = self._fill(); self.newlines = s.count(b"\n") + (not s)
        self.newlines -= 1
        return super(FastIO, self).readline()
 
    def flush(self):
        if self.writable:
            os.write(self._fd, self.getvalue())
            self.truncate(0), self.seek(0)
 
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        if py2:
            self.write = self.buffer.write
            self.read = self.buffer.read
            self.readline = self.buffer.readline
        else:
            self.write = lambda s:self.buffer.write(s.encode('ascii'))
            self.read = lambda:self.buffer.read().decode('ascii')
            self.readline = lambda:self.buffer.readline().decode('ascii')
 
 
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip('\r\n')
if __name__== "__main__":
    main()
#threading.Thread(target=main).start()

Submission status: Wrong Answer

Solution code:
def resolve():
    '''
    code here
    '''
    K = int(input())

    is_not_found = True
    memo = [0 for _ in range(K)]

    i=7%K
    memo[i] += 1
    res = 1
    while is_not_found and memo[i] == 1:
        i = (i * 10 + 7) % K
        memo[i] += 1
        res += 1
        if i == 0:
            is_not_found = False

    print(res) if is_not_found == False else print(-1)


if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
def resolve():
    '''
    code here
    '''
    K = int(input())

    is_not_found = True
    memo = [0 for _ in range(K)]

    i=7%K
    memo[i] += 1
    res = 1
    while is_not_found and memo[i] == 1:
        i = (i * 10 + 7) % K
        memo[i] += 1
        res += 1
        if i == 0:
            is_not_found = False

    print(res)


if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
k = int(input())


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


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

m = 1 % L

for i in range(k):
    m = (10 * m) % L
    if m == 1:
        print(i + 1)
        exit()
    elif i == k - 1:
        print(-1)
        exit()

Submission status: Wrong Answer

Solution code:
k = int(input())


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


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

m = 1 % L

for i in range(k):
    m = (10 * m) % L
    if m == 1:
        print(i + 1)
        exit()
    elif i == k - 1:
        print(-1)
        exit()

Submission status: Wrong Answer

Solution code:
# AtCoder Beginner Contest 174
# C - Repsept

K=int(input())

modsevens=[7]

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


for i in range (1,K+2):
    a=(modsevens[-1] *10+7)%K
    
    if a==0:
        print(i+1)
        exit()
    else:
        modsevens.append(a)

print(-1)

Submission status: Wrong Answer

Solution code:
# AtCoder Beginner Contest 174
# C - Repsept

K=int(input())

modsevens=[7]

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


for i in range (1,K+2):
    a=(modsevens[-1] *10+7)%K
    
    if a==0:
        print(i+1)
        exit()
    else:
        modsevens.append(a)

print(-1)

Submission status: Wrong Answer

Solution code:
# AtCoder Beginner Contest 174
# C - Repsept

K=int(input())

modsevens=[7]

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


for i in range (1,K+1):
    a=(modsevens[-1] *10+7)%K
    
    if a==0:
        print(i+1)
        exit()
    else:
        modsevens.append(a)

print(-1)

Submission status: Wrong Answer

Solution code:
K = int(input())

tmpNum = 7
count = 1
keisuu = 10

tmp = tmpNum%K
aa = tmp
while tmp !=0 and count<=K:
    aa = (aa*10)%K
    tmp = (tmp+aa)%K
    count+=1

if count==K:
    count=-1

print(count)

Submission status: Wrong Answer

Solution code:
K = int(input())

tmpNum = 7
count = 1
keisuu = 10

tmp = tmpNum%K
aa = tmp
while tmp !=0 and count<K:
    aa = (aa*10)%K
    tmp = (tmp+aa)%K
    count+=1

if count==K:
    count=-1

print(count)

Submission status: Wrong Answer

Solution code:
K = int(input())

if K % 2 == 0:
    print(-1)
elif K % 7 == 0:
    amari = 10
    for i in range(K):
        if i == K - 1:
            print(-1)
            break
        elif amari % int(9 * (K / 7)) == 1:
            print(i + 1)
            break
        else:
            amari = amari * 10
else:
    amari = 70
    for i in range(K):
        if i == K - 1:
            print(-1)
            break
        elif amari % int(9 * K) == 7:
            print(i + 1)
            break
        else:
            amari = amari * 10

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':

	k = int(input())
	x = 1
	for i in range(10**6):
		if x == 0:
			print(i)
			exit()
		x = (10 * x + 7) % k

Submission status: Wrong Answer

Solution code:
cnt = 1
mod = 7
k = int(input())

for i in range(k):
    if mod % k == 0:
        break
    cnt += 1
    mod = (mod * 10 * 7) % k

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

Submission status: Wrong Answer

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

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 = 9 * K // 7
    else:
        L = 9 * K
    
    b = 10 % L
    for i in range(1, 1000000):
        if b == 1:
            print(i)
            break
        else:
            b = (10 * b) % L

Submission status: Wrong Answer

Solution code:
cnt = 1
mod = 7
k = int(input())

for i in range(k):
  if mod % k == 0:
    break
  cnt += 1
  mod = (mod * 10 * 7) % k

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

Submission status: Wrong Answer

Solution code:
K = int(input())

if K % 2 == 0:
    print(-1)
elif K % 5 == 0:
    print(-1)
else:
    seven = 7
    ans = 1
    while ans < 100000:
        amari = seven % K
        if amari == 0:
            print(ans)
            break
        else:
            ans += 1
            seven = amari * 10 + 7
    else:
        print(-1)

Submission status: Wrong Answer

Solution code:
n = input()
m = 0

if n[-1] == "1":
    m = 7
elif n[-1] == "3":
    m = 9
elif n[-1] == "7":
    m = 1
elif n[-1] == "9":
    m = 3
else:
    print(-1)
    exit()

n = int(n)

for i in range(1, n):
    if len(set(list(str(n * m)))) == 1:
        break
    m = int(str(i) + str(m)[-1])
    if len(str(n * m)) >= n:
        print(-1)
        exit()

print(len(str(n * m)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
K=int(input())
C=False
count=0
for i in range(1,K+1):
  count+=1
  if (7*(10**i-1))%9*K==0:
    C=True
    break
if C:
  print(count)
else:
  print(-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s,k = "7",int(input())
for i in range(1,1000):
    if int(s * i) % k == 0:
        print(i)
        break
print(-1)

Submission status: Wrong Answer

Solution code:
s,k = "7",int(input())
for i in range(1,33):
    if int(s * i) % k == 0:
        print(i)
        break
print(-1)

Submission status: Wrong Answer

Solution code:
import math
import sys

K = int(input())

if K%2 == 0 or K%5 == 0:
  print(-1)
  sys.exit()
n = round(math.log10(K)+1)
amari = int(7*(10**n - 1)/9 % K)
if amari == 0:
  print(-1)
  sys.exit()
while True:
  if amari%K == 0:
    print(n)
    break
  amari = (amari*10 + 7)%K
  n += 1

Submission status: Wrong Answer

Solution code:
import math
import sys

K = int(input())

if K%2 == 0 or K%5 == 0:
  print(-1)
  sys.exit()
n = round(math.log10(K)+1)
amari = int(7*(10**n - 1)/9 % K)
if amari == 0:
  print(n)
  sys.exit()
while True:
  if amari%K == 0:
    print(n)
    break
  amari = (amari*10 + 7)%K
  n += 1

Submission status: Wrong Answer

Solution code:
import math
import sys

K = int(input())

if K%2 == 0 or K%5 == 0:
  print(-1)
  sys.exit()
n = round(math.log10(K)+1)
amari = int(7*(10**n - 1)/9 % K)
while True:
  if amari%K == 0:
    print(n)
    break
  amari = (amari*10 + 7)%K
  n += 1

Submission status: Wrong Answer

Solution code:
K = int(input())

n = 17
for i in range(n):
    if i == n-1:
        print(-1)
    elif int(7 * (10 ** (i + 1) - 1 ) / 9) % K == 0:
        print(i+1)
        break
print (int(7 * (10 ** (i + 1) - 1 ) / 9))

Submission status: Wrong Answer

Solution code:
N = int(input())
a=0
flag=0
for i in range(1,N+1):
    a=(a*10)+7
    p=a%N
    print(a)
    if p==0:
        print(i)
        flag=1
        break

if flag==0:
    print(-1)

Submission status: Wrong Answer

Solution code:
# your code goes here
x = int(input())
i = 1
n= 0
if x % 2 == 0 or x % 5 == 0:
    print(-1)
else:
    for i in range(1, 1000000):

        l =( 7 *pow(9,-1)* (pow(10,i,x) - 1%x) )
        n+=1
        
        if l % x == 0:
            break
    print(n)

Submission status: Wrong Answer

Solution code:
x = int(input())
i = 1
n= 0
if x % 2 == 0 or x % 5 == 0:
    print(-1)
else:
    for i in range(1, 1000000):

        l = (7*pow(9,-1)*(pow(10,i,x)-1))%x
        n+=1
        if l % x == 0:
            break
    print(n)

Submission status: Wrong Answer

Solution code:
# your code goes here
x = int(input())
i = 1
n= 0
if x % 2 == 0 or x % 5 == 0:
    print(-1)
else:
    for i in range(1, 1000000):

        l =( 7 *pow(9,-1)* (pow(10,i,x) - 1%x)%x )%x
        n+=1
        
        if l % x == 0:
            break
    print(n)

Submission status: Wrong Answer

Solution code:
# your code goes here
x = int(input())
i = 1
n= 0
if x % 2 == 0 or x % 5 == 0:
    print(-1)
else:
    for i in range(1, 1000000):

        l =( 7 *pow(9,-1)* (pow(10,i,x) - 1%x) )%x
        n+=1
        
        if l % x == 0:
            break
    print(n)

Submission status: Wrong Answer

Solution code:
K = int(input())
list = [7,77,777,7777,77777,777777]
for i in range(7):
    if i == 6:
        print(-1)
    elif list[i] % K == 0:
        print(i+1)
        break

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# your code goes here
x = int(input())
i = 1
n= 0
if x % 2 == 0 or x % 5 == 0:
    print(-1)
else:
    for i in range(1, 1000000):

        l =( 7 *pow(9,-1)* (pow(10,i,x) - 1) )%x
        n+=1
        
        if l % x == 0:
            break
    print(n)

Submission status: Wrong Answer

Solution code:
# your code goes here
x = int(input())
i = 1
n= 0
if x % 2 == 0 or x % 5 == 0:
    print(-1)
else:
    for i in range(1, 1000000):

        l =( 0.7 * (pow(10,i,x) - 1) )%x
        n+=1
        
        if l % x == 0:
            break
    print(n)

Submission status: Wrong Answer

Solution code:
x = int(input())
i = 1
n= 0
if x % 2 == 0 or x % 5 == 0:
    print(-1)
else:
    for i in range(1, 1000000):

        l = (7 * (pow(10,i,x) - 1) // 9)
        n+=1
        if l % x == 0:
            break
    print(n)

Submission status: Wrong Answer

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

print(-1)

Submission status: Wrong Answer

Solution code:
k=int(input())
s={7}
a=7
n=1
flag=True
while not {0}<=s:
    a=(a*10+7)%k
    beforelen=len(s)
    s.add(a)
    if len(s)==beforelen:
        flag=False
        break
    n+=1
print(n if flag else -1)

Submission status: Wrong Answer

Solution code:
K = int(input())
N = 10
a = 0
l = 9*K
if(K==7):
  a+=1
  print(1)
else:
  for i in range(1,10**6):
    N = (10*N)%l
    if (N*7-7)%l==0:
      print(i+1)
      a +=1
      break
  if(a == 0):
    print(-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

if k % 2 == 0 or k % 5 == 0:
  print(-1)
  
while True:
  kou += 1
  t = 10 * t + 7
  if t % k == 0:
    print(kou)
    break

Submission status: Wrong Answer

Solution code:
k=int(input())
flag=True
seq=7
"""
これは階乗を含むのでO(klogk)で重い
for i in range(1,k):
  if (7*(10**i-1)//9) % k==0:
    print(i)
    flag=False
    break
"""
for i in range(1,k):
  if seq%k==0:
    print(i)
    flag=False
    break
  seq=(seq*10+7)%k  # %k(modの考え方)がなければ10**6ではO(k)は重すぎた
  
if flag:
  print(-1)

Submission status: Wrong Answer

Solution code:
x = int(input())
i = 1
n= 0
if x % 2 or x % 5 == 0:
    print(-1)
else:
    for i in range(1, 1000000):

        l = 7 * (10**i - 1) // 9
        n+=1
        if l % x == 0:
            break
    print(n)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
k = int(input())
ch = str('')
ans = 0
if k % 2 != 0:
  for i in range(5):
    ch += str(7)
    ch_int = int(ch)
    q = ch_int // k
    mod = ch_int % k
    if q >= 1 and mod == 0:
      ans = i + 1
      break
if ans == 0:
  ans = -1
print(ans)

Submission status: Wrong Answer

Solution code:
K = int(input())
i = 0
ret = -1
if K % 5 != 0 and K % 2 != 0:
  N = 1
  if K % 7 == 0:
    L = K * 9 // 7
  else:
    L = K * 9
  while True:
    if N % L == 1:
      ret = i
      break
    N = (N * 10 )% L
    i += 1
print(ret)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
K = int(input())
N=10000
seven = '7'
tmp = '7'
num=1
for i in range(N):
    if int(tmp)%K==0:
        break
    else:
        tmp=tmp+seven
        num+=1
if num==(N+1):
    print(-1)
else:
    print(num)