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())

keta = 1 # 数列の桁数
seven = 7 # 数列の項
ans = -1 # 答え

if K % 2 == 0:
    print(ans)

else:
    while True:
        if K <= seven:
            if seven % K == 0:
                ans = keta
                break
        
        seven += 7 * (10 ** keta)
        keta += 1

print(ans)

Submission status: Wrong Answer

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

if K % 2 == 0 or K % 5 == 0:
#解なしのため何もしない
  pass
  
elif 7 % K == 0:
  Ans = 1
  
else:
  pre_modK = 7 % K
  for i in range(2,K):
    modK = pre_modK * 10 + 7
    if modK % K == 0:
      Ans = i
      break
    else:
      pre_modK = modK % K

print(Ans)

Submission status: Wrong Answer

Solution code:
K=int(input())
a=0

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

Submission status: Wrong Answer

Solution code:
K=int(input())
a=0

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

Submission status: Wrong Answer

Solution code:
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
# from scipy.sparse.csgraph import floyd_warshall
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations, combinations_with_replacement
from heapq import heappop, heappush, heapify
from fractions import gcd
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7

def main():
    n = int(input())
    ans = 1
    x = 1
    for i in range(10**7):
        if x % n == 0:
            print(i+1)
            return
        x = x*10 + 1
        x %= n
    print(-1)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
# from scipy.sparse.csgraph import floyd_warshall
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations, combinations_with_replacement
from heapq import heappop, heappush, heapify
from fractions import gcd
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7

def main():
    n = int(input())
    ans = 1
    x = 1
    for _ in range(n):
        if x % n == 0:
            print(ans)
            return
        x = x*10 + 1
        ans += 1
        if x % n == 0:
            print(ans)
            return
        x %= n
    print(-1)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
# from scipy.sparse.csgraph import floyd_warshall
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations, combinations_with_replacement
from heapq import heappop, heappush, heapify
from fractions import gcd
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7

def main():
    n = int(input())
    ans = 1
    x = 1
    for _ in range(n):
        if x % n == 0:
            print(ans)
            return
        x = x*10 + 1
        x %= n
        ans += 1
    print(-1)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
K = int(input())
ans = '-1'
mod = 7%K
path = [mod]
for i in range(1, K):
  if mod == 0:
    ans = i
    break
  mod = (mod*10 + 7)%K
  path.append(mod)
  if mod == path[0]:
    ans = '-1'
    break
print(ans)

Submission status: Wrong Answer

Solution code:
K = int(input())
res = '-1'
a = 0
for n in range(K):
  a += 7*(10**n)
  if a%K==0:
    res = n+1
print(res)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
in_num = int(input())

if in_num % 2 == 0:
    print(-1)
    exit()
elif in_num % 5 == 0:
    print(-1)
    exit()

# 数列のスタート位置を探す
ans = 1
s = 1
while s * 7 < in_num:
    s = int(str(s) + "1")
    ans += 1

import math

while True:
    x = math.gcd(in_num, s * 7)
    if x == 1:
        s = int(str(s) + "1")
        ans += 1
    else:
        print(ans)
        exit()

Submission status: Wrong Answer

Solution code:
k = int(input())

n = 7

while n < 10**8:
    if n % k == 0:
        print(len(list(str(n))))
        break
    n = n*10 + 7

print(-1)

Submission status: Wrong Answer

Solution code:
k = int(input())

n = 7

if k % 2 == 0:
    print(-1)
else:
    for i in range(10*8):
        if n % k == 0:
            print(len(list(str(n))))
            break
        else:
            n = n*10 + 7
print(-1)

Submission status: Wrong Answer

Solution code:
K = int(input())

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

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

print(-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
K = int(input())

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

Submission status: Wrong Answer

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

if 7 % k == 0:
    ans = 1

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

print(ans)

Submission status: Wrong Answer

Solution code:

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

print(ans)

Submission status: Wrong Answer

Solution code:

k = int(input())
ans = 0

if 7 % k == 0:
    ans = 1

ai = 7
for i in range(2,k+5):
    ai = ((ai * 10) + 7) % k
    if ai == 0:
        ans = i
        break
    if i == k:
        ans = -1

print(ans)

Submission status: Wrong Answer

Solution code:

k = int(input())
ans = 0

if 7 % k == 0:
    ans = 1

ai = 7
for i in range(2,k+1):
    ai = ((ai * 10) + 7) % k
    if ai == 0:
        ans = i
        break
    if i == k:
        ans = -1

print(ans)

Submission status: Wrong Answer

Solution code:

k = int(input())
ans = 0

if 7 % k == 0:
    ans = 1

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

print(ans)

Submission status: Wrong Answer

Solution code:
K = int(input())
N = 10**6
a = [0] * N

a[0] = 7
for i in range(1, N):
    a[i] = (a[i-1] * 10 + 7) % K

for i in range(N):
    if a[i] == 0:
        print(i+1)
        break
else:
    print(-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
K = int(input())
n = 7
c = 0
while c <= K:
  m = n % K
  c += 1
  if m == 0:
    break
  tmp = m * 10 + 7
  if tmp == n:
    print(-1)
    exit()
  n = tmp
print(c)

Submission status: Wrong Answer

Solution code:
K = int(input())
cal = 0
for i in range(20000):
    cal += 7*(10**i)
    if cal % K == 0:
        print(len(str(cal)))
        exit()
print("-1")

Submission status: Wrong Answer

Solution code:
K = int(input())
cal = 0
for i in range(10000):
    cal += 7*(10**i)
    if cal % K == 0:
        print(len(str(cal)))
        exit()
print("-1")

Submission status: Wrong Answer

Solution code:
import sys
K=int(input())
if K%2==0 or K%5==0:
    print('-1')
    sys.exit()
i=1
K=9*K
ans=10-K

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

Submission status: Wrong Answer

Solution code:
K = int(input())
A = 7 % K 

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

Submission status: Wrong Answer

Solution code:
K = int(input())
A = 7 % K 

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
K = int(input())
i = 1
mod = 7
answer = -1

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

print(answer)

Submission status: Wrong Answer

Solution code:
k = int(input())

a = 0

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

if i == k:
    print(-1)
else:
    print(i)

Submission status: Wrong Answer

Solution code:
k = int(input())

a = 0

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

if i == k:
    print(-1)
else:
    print(i)

Submission status: Wrong Answer

Solution code:
k=int(input())
if k&1==0:
  print(-1)
  exit()
m=7
a=b=1
while(m>0):
  a=a*10%k
  m=(m+7*a)%k
  b+=1
print(b)

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
K = int(input())

ans = -1
num7 = 7
if K%2 != 0:
    for i in range(10000):
        if (num7 % K) == 0:
            ans = i+1
            break
        else:
            num7 = num7*10+7
            i+=1

print(ans)

Submission status: Wrong Answer

Solution code:
K = int(input())

ans = -1
num7 = 7;

for i in range(10000):
    if (num7 % K) == 0:
        ans = i+1
        break
    else:
        num7 = num7*10+7
        i+=1

print(ans)

Submission status: Wrong Answer

Solution code:
K = int(input())

ans = -1
num7 = 7;

for i in range(1000):
    if (num7 % K) == 0:
        ans = i+1
        break
    else:
        num7 = num7*10+7
        i+=1

print(ans)

Submission status: Wrong Answer

Solution code:
import math
k=int(input())
if(k%2)==0:
    print("-1")
else:
    flag=0
    for x in range(1,1000001):
        if pow(10,x,k*9)==1:
            print(x)
            flag=1
            break
    if flag==0:
        print(-1)

Submission status: Wrong Answer

Solution code:
import math
k=int(input())
if(k%2)==0:
    print("-1")
else:
    for x in range(1,1000001):
        if pow(10,x,k*9)==1:
            print(x)
            break

Submission status: Wrong Answer

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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
K = int(input())
a = [0]
out = '-1'
for n in range(1, K):
  a.append((a[n-1] + 7 * (10 ** (n-1)))%K)
for i in range(1, K):
  if a[i] == 0:
    out = i
    break
print(out)

Submission status: Wrong Answer

Solution code:
n = int(input().rstrip())

def calc(target):
    result = 0
    count = 0
    if target % 2 == 0:
        return -1
        
    for i in range(n):
        result = (result * 10 + 7) % target
        count += 1
        if result == 0:
            break
    
    return count
    
print(calc(n))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#C
K = int(input())

digit=[]
Num = 0
for i in range(6):
    Num += 7*(10**i)
    if Num % K == 0:
       digit.append(i+1)
if len(digit)==0:
    print(-1)
else:
    print(min(digit))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
K = int(input())
a = 0
n = 0
out = -1
for _ in range(K):
  a += 7 * (10 ** n)
  if a % K == 0:
    out = n + 1
    break

print(out)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
K = int(input())
a = 0
n = 0
out = -1
while True:
  a += 7 * (10 ** n)
  if a % K == 0:
    out = n + 1
    print(out)
    break

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main():
  counts = 0
  target = 0
  while True:
    if k % 2 == 0:
      print(-1)
      break
    target += 7 * (10 ** count)
    if taget % k == 0:
      print(count+1)
      break
    count += 1

Submission status: Wrong Answer

Solution code:
k=int(input())
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())
a=0
if k%2==0:
  print(-1)
else:
  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())
a=0
count=1
if k%2==0:
  print(-1)
else:
  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())

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

Submission status: Wrong Answer

Solution code:
K = int(input())
s = 0; i = 0; t = 0
def seven(j):
    t = 7*(10**j)
    return t
while s == 0:
    i += 1
    u = seven(i-1) % K
    if (u*10) % K == 0:
        s = 1
        print(i)
        exit()
    else:
        s = 0

Submission status: Wrong Answer

Solution code:
K = int(input())

mods = [0] * (K+1)
mods[1] = 7 % K
for i in range(2,K+1):
    mods[i] = (mods[i-1] * 10 + 7) % K

for i in range(1,K):
    if mods[i] == 0:
        print(i)
        exit(0)    
print(-1)

Submission status: Wrong Answer

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

    crawler = 7
    found = False
    i = 1

    if (K % 2 ==0) or (K % 5 == 0):
        print(-1)
    else:
        a = [0 for i in range (K+1)]
        a[0] = 7
        for i in range (1, K+1):
            a[i] = (a[i-1]*10 + 7) % K
        for i in a:
            if i == 0:
                print(a.index(i) + 1)
                found = True
                break
        if not found:
            print(-1)
    
main()

Submission status: Wrong Answer

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

    crawler = 7
    i = 1

    if (K % 2 ==0) or (K % 5 == 0):
        print(-1)
    else:
        a = [0 for i in range (K+1)]
        a[0] = 7
        for i in range (1, K+1):
            a[i] = (a[i-1]*10 + 7) % K
        for i in a:
            if i == 0:
                print(a.index(i) + 1)
                break
                return 0
    print(-1)

main()

Submission status: Wrong Answer

Solution code:
K = int(input())

crawler = 7
i = 1

if (K % 2 ==0) or (K % 5 == 0):
    print(-1)
else:
    a = [0 for i in range (K+1)]
    a[0] = 7
    for i in range (1, K+1):
        a[i] = (a[i-1]*10 + 7) % K
    for i in a:
        if i == 0:
            print(a.index(i) + 1)
            break
print(-1)

Submission status: Wrong Answer

Solution code:

K = int(input())

crawler = 7
i = 1

if (K % 2 ==0 or K % 5 == 0):
    print(-1)
else:
    a = [0 for i in range (K+1)]
    a[0] = 7
    for i in range (1, K+1):
        a[i] = (a[i-1]*10 + 7) % K
    for i in a:
        if i == 0:
            print(a.index(i) + 1)
            break

Submission status: Wrong Answer

Solution code:
n = int(input()) 
count = 1
s="7"
found = False 
if n == 7:
  print(1)
  exit()
while(int(s) % n*count != 0 and not found):
  s = "7"*count
  count += 1
  if int(s) >= 10e6:
    print(-1)
    found = True
if not found: 
  print(count-1)

Submission status: Wrong Answer

Solution code:
n = int(input()) 
count = 1
s="7"
found = False 
while(int(s) % n*count != 0 and not found):
  s = "7"*count
  count += 1
  if int(s) >= 10e6:
    print(-1)
    found = True
if not found: 
  print(count-1)

Submission status: Wrong Answer

Solution code:
n = int(input()) 
count = 1
s="7"
while(int(s) % n*count != 0):
  s = "7"*count
  count += 1
  if int(s) >= 10e6:
    print(-1)
    exit()
print(count-1)

Submission status: Wrong Answer

Solution code:

K = int(input())
ans=-1
sevens=[7,]
for i in range(2, 7):
    sevens.append((10**(i-1))*7+sevens[i-2])
for n in sevens:
    if(n%K==0):
        ans=sevens.index(n)+1
print(ans)

Submission status: Wrong Answer

Solution code:
def solve():
    K = int(input())
    K_one = K % 10
    cnt = 0

    carry = 0
    carry_one = carry % 10

    while cnt < 10**6:
        is_ok = False
        for i in range(0,9+1):
            if (i * K_one + carry_one) % 10 == 7:
                is_ok = True
                cnt += 1
                carry = (K * i + carry) // 10
                carry_one = carry % 10
                break
        
        if not is_ok:
            print(-1)
            return
        
        carry_str = str(carry)
        if carry_str.count('7') == len(carry_str):
            print(len(carry_str) + cnt)
            return
    
    print(-1)
    
if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
K = int(input())

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

if(i == 999999):
    print('-1')
else:
    print(i+1)

Submission status: Wrong Answer

Solution code:
K = int(input())

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

if(i == 999999):
    print('-1')
else:
    print(i+1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
K = int(input())
a = [7]
for i in range(1, K+1):
    a.append((a[i-1]*10 + 7) % K)
flag = True
for i in range(len(a)):
    if a[i] == 0:
        print(i+1)
        flag = False
        break
if flag:
    print(-1)

Submission status: Wrong Answer

Solution code:
K = int(input())
a = [7]
for i in range(1, K):
    a.append((a[i-1]*10 + 7) % K)
flag = True
for i in range(len(a)):
    if a[i] == 0:
        print(i+1)
        flag = False
        break
if flag:
    print(-1)

Submission status: Wrong Answer

Solution code:
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

n = onem()


if n % 7 == 0:
    n // 7
    n *= 9
    if n % 2 and n % 5:
        co = 1
        i = 0
        while True:
            i += 1
            co *= 10
            co %= n
            if co == 1:
                break
        print(i)
    else:
        print(-1)
else:
    n *= 9
    if n % 2 and n % 5:
        co = 1
        i = 0
        while True:
            i += 1
            co *= 10
            co %= n
            if co == 1:
                break
        print(i)


    else:
        print(-1)

Submission status: Wrong Answer

Solution code:
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

n = onem()


if n % 7 == 0:
    n // 7
    n *= 9
    if n % 2 and n % 5:
        co = 1
        i = 0
        while True:
            i += 1
            co *= 10
            co %= n
            if co == 1:
                break
        print(i)
    else:
        print(-1)
else:
    if n % 2 and n % 5:
        co = 1
        i = 0
        while True:
            i += 1
            co *= 10
            co %= n
            if co == 1:
                break
        print(i)


    else:
        print(-1)

Submission status: Wrong Answer

Solution code:
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

n = onem()


if n % 7 == 0:
    n // 7
    n *= 9
    co = 1
    i = 0
    while True:
        i += 1
        co *= 10
        co %= n
        if co == 1:
            break
    print(i)

else:
    if n % 2 and n % 5:
        co = 1
        i = 0
        while True:
            i += 1
            co *= 10
            co %= n
            if co == 1:
                break
        print(i)


    else:
        print(-1)

Submission status: Wrong Answer

Solution code:
K = int(input())

cnt = 0
a = 0

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

if cnt == 0:
    print(-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math as mt

K = int(input())
a = list(range(1000001))
a[1] = 7%K
found = False

for i in range(2,K):
    a[i] = (a[i-1]*10+7)%K

for i in range(1,K):
    if a[i] == 0:
        print(i)
        found = True
        break
    
if found == False:
    print("-1")

Submission status: Wrong Answer

Solution code:
import math as mt

K = int(input())
a = list(range(1000001))
a[1] = 7%K
found = False

for i in range(2,K):
    a[i] = (a[i-1]*10+7)%K

for i in range(1,K):
    if a[i] == 0:
        print(i)
        found = True
        break
if found == False:
    print("-1")

Submission status: Wrong Answer

Solution code:
k = int(input())

x = "7"
n = 10
c = 1
f = 1
if k >=7 & k%2 != 0:
    while n>0:
        if int(x) % k == 0 : 
            f = 0
            break
        c+=1
        x += "7"
        n-=1
if f == 0: print(c)
else: print("-1")

Submission status: Wrong Answer

Solution code:
k = int(input())

x = "7"
n = 20
c = 1
f = 1
if k >=7:
    while n>0:
        if int(x) % k == 0 : 
            f = 0
            break
        c+=1
        x += "7"
        n-=1
if f == 0: print(c)
else: print("-1")

Submission status: Wrong Answer

Solution code:

k = int(input())

x = "7"
n = 10
c = 1
f = 1
if k >=7:
    while n>0:
        if int(x) % k == 0 : 
            f = 0
            break
        c+=1
        x += "7"
        n-=1
if f == 0: print(c)
else: print("-1")

Submission status: Wrong Answer

Solution code:
k = int(input())

x = "7"
n = 10
c = 1
if k >=7:
    while n>0:
        if int(x) % k == 0 : 
            break
        c+=1
        x += "7"
        n-=1
print(c)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
K = int(input())

num = 0
cnt = 0
ans = False

for i in range(K):
    num = num*10+7
    cnt += 1
    if num % K == 0:
        print(cnt)
        ans = True

if ans == False:
    print(-1)

Submission status: Wrong Answer

Solution code:
K = int(input())

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

Submission status: Wrong Answer

Solution code:
K = int(input())

if K%2==0 | K%2==5:
    print(-1)
else:
    s = 0
    for i in range(K):
        s = s*10 + 7
        if s%K!=0:
            continue
        print(i+1)
        break

Submission status: Wrong Answer

Solution code:
K = int(input())
num = K +1
i = 1
while i <= K:
  num = (10**i-1)*7//9
  if num % K == 0:
    break
  i += 1
if i > K :
  print(-1)
else:
  print(num)

Submission status: Wrong Answer

Solution code:
K = input()
num_1 = len(K)

K = int(K)

number = 7
keta = 1
count = 1
for i in range(num_1):
  num = number*keta
  count += 1
  keta = keta*10+1
  
while(1):
  num = number*keta
  if num % K ==0:
    print(count)
    break
  count += 1
  keta = keta*10+1
  if count ==10*(num_1+1) :
    print(-1)
    break

Submission status: Wrong Answer

Solution code:
import sys

K = int(input())

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

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

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

Submission status: Wrong Answer

Solution code:
K= int(input())

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

Submission status: Wrong Answer

Solution code:
K=int(input())
s=0

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

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

Solution code:
K = int(input())
mod = 0
Good = True
for k in range(K):
    mod = (mod * 10 + 7) % K
    if mod == 0:
        print(k+1)
        Good = False
if Good:
    print(-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

k = int(input())

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

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

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

print(d)