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:

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

import numpy as np
# 行数
K = int(input())
flg=False
if K==2:
  print(-1)


else:
  num = 7;
  for i in range(10000):
    # print(num)
    if num%K==0:
      flg=True
      print(i+1)
      break
    else:
      num=num*10+7

  if (is_prime(K) or is_prime(K/2)) and flg==False:
    print(K-1)
  elif(flg==False):
    print(-1)




# # S =[1]*N
# stock = 0 #株の数
# money = 1000 #所持金
# for i in range(N):
#   if i>0:
#     if A[i-1]<A[i]: #売る
#       money += stock*A[i]
#       stock = 0
#   if i!=N-1:
#     if A[i]<A[i+1]: #買う
#       stock += int(money/A[i])
#       money -= stock*A[i]
# print(money)

Submission status: Wrong Answer

Solution code:
k=int(input())

if k%2==0:
  print(-1)
  
else:
  if k<=10**5:
    for i in range(1,k+1):
      s=['7']*i
      t=int(''.join(s))
      #print(t)
      if t%k==0:
        print(i)
        break
  else:
    for i in range(k,10**5-1,-1):
      s=['7']*i
      t=int(''.join(s))
      #print(t)
      if t%k==0:
        print(i)
        break

Submission status: Wrong Answer

Solution code:
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0:
        cnt+=1
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr
n=int(input())
a=[7]
for i in range(30000):
  a.append(a[-1]*10+7)
if n%2==0 or n%5==0:
  print(-1)
else:
  flg=0
  for i in a:
    if i%n==0:
      print(len(str(i)))
      flg=1
      break
  if flg==0:
    f=factorization(n)
    print(f[-1][0]-1)

Submission status: Wrong Answer

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

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

x = '7' * n
if int(x) < k:
   x += '7'
   n += 1

q = int(x) // k
r = int(x) % k
while r > 0:
   n += 1
   q *= 10
   y = r*10 + 7
   q += y // k
   r = y % k
   if n > 10:
      n = k - 1
      break
print(n)

Submission status: Wrong Answer

Solution code:
K = int(input())
y=7
kotae=-1
for i in range(0,10^6):
    if y%K==0:
        kotae=i+1
        break
    else:
        y=y*10+7
print(kotae)

Submission status: Wrong Answer

Solution code:
a = int(input())
b = "7"
if a % 2 == 0:
  print("-1")
else:
  while int(b) % a != 0:
    b = b + "7"
print(str(len(b)))

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,7000):
    if int("7"*i)%K == 0:
        print(i)
        exit()
print(K-1)

Submission status: Wrong Answer

Solution code:
k=int(input())
if k%2==0 or k%5==0:
    print(-1)
    exit()
lep=7
for i in range(1,1000001):
    lep+=7*(pow(10,i,k))%k
    if lep%k==0:
        print(i+1)
        exit()
print(-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
import math
import itertools
import bisect
from copy import copy,deepcopy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(map(int,input().split()))
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

K = i()
if K == 7:
  print(1)
  exit()
if K%7 == 0:
  K = K//7
if K%2 == 0 or K%5 == 0:
    print(-1)
    exit()
m = 1
for i in range(1,40000):
    m *= 10
    if (m-1)%K == 0:
        print(i)
        exit()
print(K-1)

Submission status: Wrong Answer

Solution code:
k = int(input())

count = 0
ans = 1

while True:
  num = int("7" + "7" * count)
  if num % k == 0:
    print(ans)
    break
  if num < k:
    print(-1)
    break
  count += 1
  ans += 1

Submission status: Wrong Answer

Solution code:
K= int(input())
ans = -1
if K % 2:
    last = len(str(K)) * "7"
    for i in range(1, 64):
        last += "7"
        #print(last)
        if int(last) % K == 0:
            ans = i
            break
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from collections import defaultdict 
import sys
import math 

def get_array(): return list(map(int , sys.stdin.readline().strip().split()))
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def input(): return sys.stdin.readline().strip()

n = int(input())

def repUnitValue(n): 
      
    # To check n is coprime or not 
    if (n % 2 == 0 or n % 5 == 0): 
        return -1
  
    # to store R(k) mod n and 10^k 
    # mod n value 
    rem = 1
    power = 1
    k = 1
    while (rem % n != 0): 
          
        k += 1
        power = power * 10 % n 
        rem = (rem + power) % n 
      
    return k 

print(repUnitValue(n))

Submission status: Wrong Answer

Solution code:
#C
K = int(input())
judge=False
num = 0
for i in range(K+1):
    num += 7 * (10**i)
    num == num % K
    if num == 0:
        judge=True
        print(i+1)
        break
if judge == False:print("-1")

Submission status: Wrong Answer

Solution code:
n = int(input())

ans,c = 0,0
s = str(n)
co =  s.count('1')
if co==len(s):
    print(1)
    exit()

while 1:
    c+=1
    f=0
    for i in range(10):
        if ((ans%10)+((n%10)*i)%10)%10==1:
            ans += n*i
            #print(ans,i)
            f=1
            break
    if f==0:
        print(-1)
        exit()
    ans = ans//10
    if ans==0:
        break
print(c)

Submission status: Wrong Answer

Solution code:
k = int(input())
n = '7'
cnt = 1
if k % 2 == 0:
    print(-1)
else:
    while cnt <= 50:
        num = int(n)
        if num%k == 0:
            print(cnt)
            break
        elif cnt == 50:
            print(k-1)
            break
        else:
            cnt += 1
            n += '7'

Submission status: Wrong Answer

Solution code:
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

k = INT()
x = 0
for i in range(10**4):
    x = ( x + 7*10**i ) % k
    if x % k == 0:
        print(i+1)
        exit()
if k != 2 and k != 5:
    if k % 7 == 0:
        print(k//7-1)
    else:
        print(k-1)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
import math
import sys
K  =int( input() )
seven = "7"
count = 1

for i in range( len( str(K) ) ) :
    seven = seven + "7"
    count += 1

for i in range (10**6):
    if int(seven) % K  == 0:
        print(count)
        sys.exit()

    else:
        count += 1  
        seven = seven + "7"

print("-1")

Submission status: Wrong Answer

Solution code:
K = int(input())

seven_val = 0

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

Submission status: Wrong Answer

Solution code:
from sys import stdin
import math

n = int(stdin.readline().rstrip())
count = 1
like = 7
a = 7
if n % 2 == 0 or n <= 0:
  print(-1)

else:
  while(a % n != 0):
    a = a + like * (10 ** count)
    count = count + 1
    if(a % n == 0):
      print(count)
      break

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
k = int(input())

count = 0
ans = 1

while True:
  num = int("7" + "7" * count)
  if num % k == 0:
    print(ans)
    break
  if num > 7777777:
    print("-1")
    break
  count += 1
  ans += 1

Submission status: Wrong Answer

Solution code:
K = int(input())
if K % 10 in [2,4,5,8,0]:
    print(-1)
else:
    sevens = [int(("7"*i)) % K for i in range(1,K)]
    try:
        print(sevens.index(0)+1)
    except Exception as e:
        print(-1)

Submission status: Wrong Answer

Solution code:
k = int(input())
n = '7'
cnt = 1
if k % 2 == 0:
    print(-1)
else:
    while cnt <= 50:
        num = int(n)
        if num%k == 0:
            break
        elif cnt == 50:
            print(k-1)
            break
        else:
            print(num%k)
            cnt += 1
            n += '7'

Submission status: Wrong Answer

Solution code:
K = int(input())

n = 1
x = 7


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

while 1:
  if x % K == 0:
    print( n )
    break
  x = (x % K) * 3 + 7
  n += 1
#

Submission status: Wrong Answer

Solution code:

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

import numpy as np
# 行数
K = int(input())
flg=False
if K==2:
  print(-1)


else:
  num = 7;
  for i in range(10000):
    # print(num)
    if num%K==0:
      flg=True
      print(i+1)
      break
    else:
      num=num*10+7

  if is_prime(K) and flg==False:
    print(K-1)
  elif(flg==False):
    print(-1)




# # S =[1]*N
# stock = 0 #株の数
# money = 1000 #所持金
# for i in range(N):
#   if i>0:
#     if A[i-1]<A[i]: #売る
#       money += stock*A[i]
#       stock = 0
#   if i!=N-1:
#     if A[i]<A[i+1]: #買う
#       stock += int(money/A[i])
#       money -= stock*A[i]
# print(money)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

k = INT()
x = 0
for i in range(10**4):
    x = ( x + 7*10**i ) % k
    if x % k == 0:
        print(i+1)
        exit()
if k % 2 != 0 and k % 5 != 0:
    if k % 7 == 0:
        print(k//7-1)
    else:
        print(k-1)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
A = int(input())

if A>777777:
  print(-1)
elif A<7:
  print(-1)
elif A<=7 and 7%A==0:
  print(1)
elif A<=77 and 77%A==0:
  print(2)
elif A<=777 and 777%A==0:
  print(3)
elif A<=7777 and 7777%A==0:
  print(4)
elif A<=77777 and 77777%A==0:
  print(5)
elif A<=777777 and 777777%A==0:
  print(6)

Submission status: Wrong Answer

Solution code:
#200802C
X = int(input())
L = len(str(X))
#print(L)


Y = 0

for l in range(L):
    Y += 7*10**l
    
flag = 0
for i in range(100000):
    Y = Y%X
    #print(i)

    if Y == 0:
        ans = L+i
        flag = 1
        break
    else: 
        Z = Y * 10 + 7
        if Z == Y:
            break
        else:
            Y = Z

if flag == 0:
    print("-1")
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


K = int(input())
ans = -1
if K == 1:
    ans = 1
if K == 3:
    ans = 3
if K % 2 == 1:
    cds = make_divisors(K)
    for cd in cds:
        cd = make_divisors(cd - 1)
        for num in cd:
            if int("7" * num) % K == 0:
                ans = num
                break
        if ans != -1:
            break
print(ans)

Submission status: Wrong Answer

Solution code:
k=int(input())
ans=0
n=7
if k%2==0:
  ans=-1
cnt=0
while ans==0 and cnt<65:
  cnt+=1
  if n%k==0:
    ans=cnt
  n=n*10+7
if ans==0:
  ans=k-1
print(ans)

Submission status: Wrong Answer

Solution code:
k = int(input())
n = '7'
cnt = 1
if k % 2 == 0:
    print(-1)
else:
    while cnt <= 50:
        num = int(n)
        if num%k == 0:
            print(cnt)
            break
        elif cnt == 50:
            print(k-1)
            break
        else:
            print(num%k)
            cnt += 1
            n += '7'

Submission status: Wrong Answer

Solution code:
t = int(input())
c = 1
N = '7'*len(str(t))
N = int(N)
f=0

while(N%t !=0):
        c +=1
        N = N*10 + 7
        if(len(str(N))>10001):
            print(-1)
            f=1
            break
if(f!=1):
        print(c)

Submission status: Wrong Answer

Solution code:
k=int(input())

if k%2==0:
  print(-1)
  
else:
  if k<=10**3:
    for i in range(1,k+1):
      s=['7']*i
      t=int(''.join(s))
      #print(t)
      if t%k==0:
        print(i)
        break
  else:
    for i in range(k,10**3-1,-1):
      s=['7']*i
      t=int(''.join(s))
      #print(t)
      if t%k==0:
        print(i)
        break

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
K = int(input())
n = "7"*(len(str(K))+1)
m = "7"*len(str(K))
p = int(n)
ans = 0
flag = 0
if(K%2==0):
  print("-1")
else: 
  while(ans <= K):
    ans += 1
    q = p % K
    p = str(q) + "7"
    p = int(p)
    if(q==0):
      print(ans+len(str(K)))
      flag = 1
      break
  if(flag==0):
    print("-1")

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

n = input()
l = len(n)
p = int(n)
cnt = -1

if p % 2 != 0:
    for i in range(1,10):
        a = prime_factorize(int('7'*i))
        #print(a)
        if p in a:
            print(i)
            break
    else:
        print(p-1)
else:
    print(-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import numpy as np
import sys
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect
from scipy.special import comb
import copy
sys.setrecursionlimit(10**6)

# lis_of_lis = [[] for _ in range(N)]


def zz():
    return list(map(int, sys.stdin.readline().split()))


def z():
    return int(sys.stdin.readline())


def S():
    return sys.stdin.readline()[:-1]


def C(line):
    return [sys.stdin.readline() for _ in range(line)]


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


K = z()
if (K == 1):
    print(1)
    exit()
elif (K % 2 == 0):
    print(-1)
    exit()
elif (K % 5 == 0):
    print(-1)
    exit()
v = '7'
for i in range(1, 1000+1):
    seven = int(v)
    if (seven % K == 0):
        # print(seven)
        print(i)
        exit()
    v = v + '7'

if(is_prime(K)):
    print(K-1)
    exit()
else:
    print(-1)
    exit()

Submission status: Wrong Answer

Solution code:
K = int(input())
x = [7, 77, 777, 7777, 77777, 777777]
Count = 0
flag="FALSE"
for i in x:
    Count = Count + 1
    if (i % K)==0:
        flag="TRUE"
        break

if flag=="FALSE":
    Count = -1

print(Count)

Submission status: Wrong Answer

Solution code:
K = int(input())
if K % 10 in [2,4,5,8,0]:
    print(-1)
else:
    sevens = [int(("7"*i)) % K for i in range(1,K)]
    try:
        print(sevens.index(0))
    except Exception as e:
        print(-1)

Submission status: Wrong Answer

Solution code:

def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
count = 0
ans = -1

K = i()
N = 1
s = 10
if K == 7:
    print(1)
    exit()
if K % 2 == 0:
    print(-1)
    exit()

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

Submission status: Wrong Answer

Solution code:
k = int(input())

count = 0
ans = 1

while True:
  num = int("7" + "7" * count)
  if num % k == 0:
    print(ans)
    break
  if num > 7777777:
    print(-1)
    break
  count += 1
  ans += 1

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
K = int(input())
flag = 0
seven = 0
if K % 2 != 0:
  for i in range(10000):
    seven = seven * 10 + 7
    if seven % K == 0:
      ans = i + 1
      flag = 1
      break
else:
  flag = 2
if flag == 2:
  print(-1)
elif flag == 0:
  print(K-1)
else:
  print(ans)

Submission status: Wrong Answer

Solution code:
k = int(input())

number = 1
Seq = 7

while True:

    if Seq > 10**6:
        print(-1)
        break
    elif Seq % k == 0:
        print(number)
        break
    else:
        Seq = Seq + 7 * (10 ** number)
        number += 1

Submission status: Wrong Answer

Solution code:
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

k = INT()
chk = True
if k == 2:
    chk = False
else:
    for i in range(2, ceil(sqrt(k))):
        if k % i == 0:
            chk = False
            break

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

Submission status: Wrong Answer

Solution code:
k = int(input())
n = '7'
cnt = 1
if k % 2 == 0:
    print(-1)
else:
    while cnt <= 50:
        num = int(n)
        if num%k == 0:
            print(cnt)
            break
        else:
            print(num%k)
            cnt += 1
            n += '7'

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

n = input()
l = len(n)
p = int(n)
cnt = -1

if p % 2 != 0:
    for i in range(1,l*2+1):
        a = prime_factorize(int('7'*i))
        #print(a)
        if p in a:
            print(i)
            break
    else:
        print(p-1)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
from itertools import cycle

K = int(input())


tmp = 10
seq1 = [tmp % K]
for i in range(K+1):
    tmp = (tmp * 10) % K
    if seq1[0] == tmp % K:
        break
    seq1.append(tmp % K)

if K % 7 == 0:
    K //= 7

result = 1
tmp = 1
start = tmp % K
for x in cycle(seq1):
    if tmp == 0:
        print(result)
        exit()
    tmp = (tmp + x) % K
    result += 1
    if tmp == start and x == seq1[0]:
        print(-1)
        exit()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
K = int(input())
c = 1
b = False
 
while b == False:
  n = 0
  for i in range(c):
    n += 7 * (10 ** i)
  if n % K == 0:
    b = True
    print(c)
  c += 1
  if c > 100:
    print(-1)
    b = True

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
A = int(input())

if A<=7 and 7%A==0:
  print(1)
elif A<=77 and 77%A==0:
  print(2)
elif A<=777 and 777%A==0:
  print(3)
elif A<=7777 and 7777%A==0:
  print(4)
elif A<=77777 and 77777%A==0:
  print(5)
elif A<=777777 and 777777%A==0:
  print(6)
else:
  print(-1)

Submission status: Wrong Answer

Solution code:
k=int(input())
ama=[0]*(k)
now=0
for i in range(1,3*k):
  now=7*(10**i-1)//9
  tem=now%k
  print(tem)
  if ama[tem]==0 and tem!=0:
    ama[tem]+=1
  elif ama[tem]!=0:
    print(-1)
    exit()
  elif tem==0:
    print(i)
    exit()

Submission status: Wrong Answer

Solution code:
k = int(input())
nums = ""
ans = []
number = 0
if k % 2 == 1:
    for _ in range(15):
        nums += "7"
        if int(nums) % k == 0:
            number = int(nums)
            break
    for i in range(1, k + 1):
        if number % i == 0:
            ans.append(i)
    if max(ans) <= 10 ** 6:
        print(ans.index(k))
    else:
        print(-1)
else:
    print(-1)

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
if len(prime_factorize(K)) == 1:
    print(K-1)
    exit(0)
print(prime_factorize(K))
cnt = 1
if K%2 ==0:
    print(-1)
    exit(0)
for i in range(1000000):
    if seven%K == 0:
        print(cnt)
        exit(0)
    seven += plus*10**i
    cnt += 1

Submission status: Wrong Answer

Solution code:
K = int(input())
n = "7"*(len(str(K))+1)
m = "7"*len(str(K))
p = int(n)
ans = 0
if(K%2==0):
  print("-1")
else: 
  while(1):
    ans += 1
    q = p % K
    p = str(q) + "7"
    p = int(p)
    if(q==0):
      print(ans+len(str(K)))
      break

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]
ans7 = [239, 239*7, 4649, 4649*7]

Ans = [ans1, ans2, ans3, ans4, ans5, 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:
            if ans == ans7:
                i += 1
            print(i+1)

Submission status: Wrong Answer

Solution code:
  
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

import numpy as np
# 行数
K = int(input())
flg=False
if K==2:
  print(-1)

elif is_prime(K):
  print(K-1)

else:
  num = 7;
  for i in range(10000):
    # print(num)
    if num%K==0:
      flg=True
      print(i)
      break
    else:
      num=num*10+7

  if(flg==False):
    print(-1)




# # S =[1]*N
# stock = 0 #株の数
# money = 1000 #所持金
# for i in range(N):
#   if i>0:
#     if A[i-1]<A[i]: #売る
#       money += stock*A[i]
#       stock = 0
#   if i!=N-1:
#     if A[i]<A[i+1]: #買う
#       stock += int(money/A[i])
#       money -= stock*A[i]
# print(money)

Submission status: Wrong Answer

Solution code:
k = int(input())
count = 0
temp = ''
remainder = 0
reminder_list = []

while True:
    count += 1
    temp += '7' # 7, 77, 777,,,
    reminder = int(temp) % k
    print(reminder)
    if reminder in reminder_list:
        count = -1
        break
    if reminder == 0:
        break
    else:
        temp = str(reminder % k)
    reminder_list.append(reminder)
print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
k = int(input())

count = 0
ans = 1

while True:
  num = int("7" + "7" * count)
  if ans > 6:
    print("-1")
    break
  if num % k == 0:
    print(ans)
    break
  count += 1
  ans += 1

Submission status: Wrong Answer

Solution code:
K,=list(map(int, input().split()))
se = 7
fiv = 1
for i in range(1,1000000):
  if K < se:
    st = i
    break
  fiv *= 10 
  se = se + 7 * fiv
q1 = 7 * fiv % K
q2 = se % K
for i in range(st,1000000):
  if q2!=0:
    q1 = (10*q1) % K 
    q2 = (q1+q2)%K
    continue
  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()]

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

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

    print(i)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
import time
k=int(input())
start=time.time()
if k%2==0:
    print(-1)
    sys.exit()
num=7
cnt=1
while time.time()-start<=1.6:
    if num%k==0:
        print(cnt)
        sys.exit()
    num=num*10+7
    cnt+=1
print(-1)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[7]
for i in range(40000):
  a.append(a[-1]*10+7)
if n%2==0 or n%5==0:
  print(-1)
else:
  flg=0
  for i in a:
    if i%n==0:
      print(len(str(i)))
      flg=1
      break
  if flg==0:
    print(n-1)

Submission status: Wrong Answer

Solution code:
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

k = INT()
chk = True
for i in range(2, ceil(sqrt(k))):
    if k % i == 0:
        chk = False
        exit()

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

Submission status: Wrong Answer

Solution code:
n = int(input())

ans,c = 0,0

while 1:
    c+=1
    f=0
    for i in range(10):
        if ((ans%10)+((n%10)*i)%10)%10==1:
            ans += n*i
            #print(ans,i)
            f=1
            break
    if f==0:
        print(-1)
        exit()
    ans = ans//10
    if ans==0:
        break
print(c)

Submission status: Wrong Answer

Solution code:
import math

k = int(input())
if k % 2==0:
    print(-1)
else:
    keta = math.floor((math.log(k ,10))) + 1
    n = keta
    p = 0
    for i in range(keta):
        p += 7*(10**(i))
    if k % 3 == 0:
        while(n%3 != 0):
            n += 1
            p  += 7  *  10**(n-1)
        if p % k ==  0:
            print(n)
        else:
            n += 3
            p  += 777  *  10**(n-3)
    else:
        while(True):
            if p % k ==  0:
                print(n)
                break
            else:
                n += 1
                p  += 7  *  10**(n-1)