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:
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate, product, combinations_with_replacement
import sys
import bisect
import string
import math
import time


def I(): return int(input())
def S(): return input()
def MI(): return map(int, input().split())
def MS(): return map(str, input().split())
def LI(): return [int(i) for i in input().split()]
def LI_(): return [int(i)-1 for i in input().split()]
def StoI(): return [ord(i)-97 for i in input()]
def ItoS(nn): return chr(nn+97)
def input(): return sys.stdin.readline().rstrip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def print_matrix(mat):
    for i in range(len(mat)):
        print(*['IINF' if v == IINF else "{:0=4}".format(v) for v in mat[i]])


yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**19
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
show_flg = False
# show_flg = True

def count_ones(n):

    # to store number of 1s
    # in smallest repunit
    # multiple of the number.
    count = 1;

    # initialize rem with 1
    rem = 7

    # run loop until
    # rem becomes zero
    while rem != 0:
        # rem*10 + 1 here represents
        # the repunit modulo n
        rem = (rem * 10 + 7) % n
        count = count + 1

    # when remainder becomes
    # 0 return count
    return count

def main():
    K = I()
    MAX = 10 ** 6

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

    print(count_ones(K))



if __name__ == '__main__':
    main()

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,15):
        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=input()
if int(k)%2==0:
    print(-1)
else:
    s='7'
    flag=0
    for _ in range(12):
        if int(s)%int(k)==0:
            flag=1
            print(len(s))
            break
        s=s+'7'
    if flag==0 and k[-1]=='3':
        print(int(k)-1)
    else:
        print(-1)

Submission status: Wrong Answer

Solution code:
import math

def is_prime(n):
    if n == 1: return False
    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True

def f(x):
    return 7*(10**x-1)//9

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

if not is_prime(K) or 2<=K<=6:
    print(-1)
    exit

ans = K-1
print(ans)



# for y in range(10**6):
#     if 9*K*y % 7 != 0:
#         continue
#     t = 9*K*y/7 + 1
#     if t % 10 == 0:
#         a = math.log(t, 10)
#         b = int(a)
#         if a==float(b):
#             ans = b
#             break

Submission status: Wrong Answer

Solution code:
K = int(input())

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

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

print(cnt)

Submission status: Wrong Answer

Solution code:
import math
k = int(input())
sevens = []
for i in range(1, 6):
    sevens.append("7"*i)

sevens2 = [int(s) for s in sevens]
ans = []

for i in range(0, len(sevens)):
    if sevens2[i]%k == 0:
        ans.append(i+1)

if ans:
    print(min(ans))
elif k%2 == 0:
    print(-1)
elif k ==5:
    print(-1)
else:
    print(k-1)

Submission status: Wrong Answer

Solution code:
k = int(input())
if k % 2 == 0:
    print(-1)
elif k > 999983:
    print(-1)
elif k == 999983:
    print(999982)
else:
    flag = True
    for crs in range(1, int(k/2.0+1), 2):
        f_now = k * crs
        f_now_s = str(f_now)
        b_now = k * (k+1-crs)
        b_now_s = str(b_now)
        if f_now_s.count('7') == len(f_now_s):
            print(len(f_now_s))
            flag = False
            break
        elif b_now_s.count('7') == len(b_now_s):
            print(len(b_now_s))
            flag = False
            break
    if flag:
        print(-1)

Submission status: Wrong Answer

Solution code:
k=int(input())
a=""
b=""
ans=-1
for i in range(100000):
    a+="7"
    b=str(k%int(a)).replace("7","")
    if b=="":
        ans=i+1
        break
print(ans)

Submission status: Wrong Answer

Solution code:
K = int(input())

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

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

print(cnt)

Submission status: Wrong Answer

Solution code:
import math
K = int(input())

S = [int('7' * i) for i in range(1, 7)]
start = math.floor(math.log(K, 10))
count = [a for a in S[start:] if a % K == 0]
if len(count) == 0:
    print(-1)
else:
    print(len(str(count[0])))

Submission status: Wrong Answer

Solution code:
k = int(input())
if k % 2 == 0:
    print(-1)
 
amari = [7]
tmp = 7
for i in range(k+1):
    tmp = (tmp * 10) % k
    if tmp != 7:
        amari.append(tmp%k)
    else:
        break
amari = amari * ((k//len(amari)) +1)
 
ans = amari[0]
for i in range(1, k+1):
    ans += amari[i]
    if ans % k == 0:
        print(i+1)
        break
else:
  print(-1)

Submission status: Wrong Answer

Solution code:
K = int(input())

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

seven = 0
for i in range(10**4):
    seven = seven * 10 + 7
    if seven % K == 0:
        print(i + 1)
        exit()

if K == 999983:
    print(999982)
    exit()

print(-1)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
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


K = int(input())
# = "7"*999982
#print(int(t)%999983)


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

else:
    f = len(factorization(K))
    i = 0
    while(5000>i):
        i+=1
        if 7 * (10**i-1)//9 %K == 0:
            print(i)
            break
    if f > 2:
        print(-1)
    else:
        print(K-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,15):
        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:
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
#======================================================#
def main():
    k = II()
    print(-1)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

K = INT()

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

#素数判定
def is_prime(num):
	if 2 > num:
		return False
	if num in [2, 3, 5]:
		return True
	if num%2 == 0 or num%3 == 0 or num%5 == 0:
		return False
	#擬似素数(2でも3でも割り切れない数)で割っていく。(周期6)
	prime = 7
	step = 4
	while num**0.5 >= prime:
		if num%prime == 0:
			return False
		prime += step
		step = 6 - step
	return True

for i in range(2, K):
	t = str(i*K)
	if set(t) == {"1"}:
		print(len(t))
		break
else:
	if is_prime(K) and K != 2 and K != 5:
		print(K-1)

Submission status: Wrong Answer

Solution code:
K = int(input())

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

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

print(cnt)

Submission status: Wrong Answer

Solution code:
K=int(input())
N=1
c=0
if K%2==0:
    print("-1")
else:
    while N % K != 7 % K:
        c += 1
        N = 7 * (10 ** c)
print(c)

Submission status: Wrong Answer

Solution code:
k = int(input())
u = k%10
if(u == 1):
	l =  len(str(k))
	print(l*2-2)
elif(u==3 or u==9):
	print(k-1)
else:
	print(-1)

Submission status: Wrong Answer

Solution code:
import sys
K = int(input())
l_begin = 7
count = 1
for i in range(1000):
    if l_begin % K == 0:
        print(count)
        sys.exit()
    l_begin = 10 * l_begin + 7
    count += 1
print(-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==0 or K%5==0:
  print(-1)


else:
  num = 7;
  for i in range(50000):
    # 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:
N=int(input())
if N%2==0:
    print(-1)
    exit()
num=7
ans=-1
for i in range(1,10*8):
    if num%N==0:
        ans=i
        break
    num=str(num)
    num+='7'
    num=int(num)
if i ==79:
    print(N-1)
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
def solve(n):
    if n % 10 not in [1,3,7]:
        return -1
    r = 0
    for i in range(int(1.2e6)):
        r = (r * 10 + 7) % n
        if r == 0:
            return i + 1
    return -1

print(solve(int(input())))

Submission status: Wrong Answer

Solution code:
K = int(input())
Klen = len(str(K))
cnt = 0
arr = []

for j in range(1,K):
  cmp = int("7"*j)%K
  if cmp == 0:
    print(j)
    exit()
    
print(-1)

Submission status: Wrong Answer

Solution code:
k=int(input())
if not k&1:
    print(-1)
    exit()
ks=str(k)
carry=0
d1=int(ks[-1])
i=1
while i<=5*(10**7):
    flag=False
    car=int(carry)
    for j in range(0,10):
        if (d1*j+car)%10==7:
            carry=str((car+k*j)//10)
            if len(carry)==carry.count('7'):
                print(i+len(carry))
                exit()
            flag=True
            break
    if not flag:
        print(-1)
        exit()
    i+=1

Submission status: Wrong Answer

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


if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

Solution code:
k = int(input())
seven = 7
i = 1
if k % 2 == 0:
    print(-1)
else:
    while seven < k:
        seven = seven + 7 * 10**i
        i +=1
        ans = seven
        
    while seven % k != 0:
        seven = seven + 7 * 10**i
        i +=1
        if i >101:
            i = k-1
            break
    print(i)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
k = int(input())

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

Submission status: Wrong Answer

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

for i in range(1, k + 1):
    number = k * i
    count_7 = str(number).count("7")
    if count_7 == len(str(number)):
        print(count_7)
        exit()
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())
if  k%2==0 or k%5==0:
    print(-1)
else:
    se = prime_factorize(k)
    k_ = k
    if not 7 in se:
        k_ = k*7

    K = int(str(k_)[-1])
    # print(K)
    if K==1:
        # print("a")
        x = 7
    elif K==3:
        x=9
    elif K==7:
        x = 1
    elif K==9:
        x = 3
    z = 0
    # print(x)
    while True:
        s = 10*z + x
        q = k_ * s
        print(q)
        if str(q)=="7"*len(str(q)):
            print(len(str(q)))
            break
        z+=1

Submission status: Wrong Answer

Solution code:
K=int(input())

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

c=0
x=0
Y=x%K

while x<=K:
  x=(7*10**c)+x
  c=c+1

while Y==0:
    Y=x%K
    x=(7*10**c)+x
    c=c+1

print(c)

Submission status: Wrong Answer

Solution code:
K = int(input())

n1 = "7"*len(str(K))
n2 = "7"*K
cnt = K
for i in range(len(str(K)), K):
    if int(n1) % K == 0:
        print(i)
        break
    if int(n2) % K == 0:
        print(cnt)
    n1 += "7"
    n2.rstrip()
    cnt -= 1
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
print(int(input())-1)

Submission status: Wrong Answer

Solution code:
from sys import stdin
import math

p = int(stdin.readline().rstrip())
count = 1
like = 7
a = 7
if p % 2 == 0 or p <= 0:
  print(-1)
if p == 7:
  print(1)
else:
  while(a % p != 0):
    a = a + like * (10 ** count)
    count = count + 1
    if(a % p == 0):
      print(count)
      break

Submission status: Wrong Answer

Solution code:
k = int(input())
if k % 2 == 0 or k % 5 == 0 or k % 10 == 1:
    print('-1')
else:
    if k % 7 == 0:
        k //= 7
    s =  '1'
    ans = 1
    while True:
        if int(s) % k == 0:
            print(ans)
        else:
            ans += 1
            s += '1'

Submission status: Wrong Answer

Solution code:
k=int(input())
if not k&1:
    print(-1)
    exit()
ks=str(k)
carry=0
d1=int(ks[-1])
i=1
while i<=10**7+8*(10**6):
    flag=False
    car=int(carry)
    for j in range(0,10):
        if (d1*j+car)%10==7:
            carry=str((car+k*j)//10)
            if len(carry)==carry.count('7'):
                print(i+len(carry))
                exit()
            flag=True
            break
    if not flag:
        print(-1)
        exit()
    i+=1

Submission status: Wrong Answer

Solution code:
import sys
K = int(input())
l_begin = 7
count = 1
for i in range(100):
    if l_begin % K == 0:
        print(count)
        sys.exit()
    l_begin = 10 * l_begin + 7
    count += 1
print(-1)

Submission status: Wrong Answer

Solution code:
X = int(input())
if X%2==0:
  print(-1)
  exit()
if X%7==0:
  for num in range(1000000):
    l = list(str(X*num/7))
    if l.count("1")== len(l):
      print(len(l))
      exit()
else:
  for num in range(1000000):
    l = list(str(X*num))
    if l.count("1")== len(l):
      print(len(l))
      exit()

Submission status: Wrong Answer

Solution code:
def solve(n):
    if n % 10 not in [1,3,7]:
        return -1
    r = 0
    for i in range(int(1.2e6)):
        r = (r * 10 + 7) % n
        if r == 0:
            return i + 1

print(solve(int(input())))

Submission status: Wrong Answer

Solution code:
#-*-coding:utf-8-*-

import sys

def main():
    k = int(input())
    mod=999983
    if k % 2==0:
        print(-1)
        exit()
    sevens=7
    for i in range(1,10**6+1):
        if sevens%k==0:
            print(i)
            exit()
        else:
            sevens=(sevens*10+7)%mod

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
K = int(input())
if K % 2 == 0:
    print(-1)
else:
    if K == 7:
        print(1)
    else:
        mod = K
        t = 7
        for _ in range(K+1):
            t *= 10
            t += 7
            if t % mod == 0:
                print(_+2)
                exit(0)
            else:
                t %= mod
        print(-1)

Submission status: Wrong Answer

Solution code:
import math
k = int(input())
sevens = []
for i in range(1, 6):
    sevens.append("7"*i)

sevens2 = [int(s) for s in sevens]
ans = []

for i in range(0, len(sevens)):
    if sevens2[i]%k == 0:
        ans.append(i+1)

if ans:
    print(min(ans))
elif k%2 == 0:
    print(-1)
else:
    print(k-1)

Submission status: Wrong Answer

Solution code:
k = int(input())

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

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


print(ans)

Submission status: Wrong Answer

Solution code:
k=int(input())
if not k&1:
    print(-1)
    exit()
ks=str(k)
carry=0
d1=int(ks[-1])
i=1
while i<=10**7+5*(10**6):
    flag=False
    car=int(carry)
    for j in range(0,10):
        if (d1*j+car)%10==7:
            carry=str((car+k*j)//10)
            if len(carry)==carry.count('7'):
                print(i+len(carry))
                exit()
            flag=True
            break
    if not flag:
        print(-1)
        exit()
    i+=1

Submission status: Wrong Answer

Solution code:
a=int(input())

ans=[]
num=0
for i in range(10000):
    num=num*10+7
    ans.append(num)
#print(ans)

cnt=0
for x in ans:
    if x%a==0:
        print(cnt+1)
        break
    cnt+=1

Submission status: Wrong Answer

Solution code:
import math

def is_prime(n):
    if n in [1, 2, 3, 5]: 
        return False
    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True


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


# @patch('builtins.input', test.test_input)
def main():
    n = int(input())
    if n%7 == 0:
        n = n // 7
    if n in [1, 7]:
        print(1)
    elif n == 3:
        print(3)
    elif is_prime(n):
        l = sorted(divisor(n-1), reverse=True)
        ans = l[0]
        for i in l[1:]:
            if int('7'*i)%n==0:
                ans = i
        print(ans)
                
    else:
        print(-1)

    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
k = int(input())
if k % 2 == 0:
    print(-1)
elif k > 999983:
    print(-1)
elif k == 999983:
    print(999982)
else:
    flag = True
    for crs in range(3, k, 2):
        f_now = k * crs
        f_now_s = str(f_now)
        b_now = k * (k+1-crs)
        b_now_s = str(b_now)
        if f_now_s.count('7') == len(f_now_s):
            print(len(f_now_s))
            flag = False
            break
        elif b_now_s.count('7') == len(b_now_s):
            print(len(b_now_s))
            flag = False
            break
    if flag:
        print(-1)

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())
for i in range(1, 14):
    if K % 2 == 0:
        print('-1')
        break
    lis=make_divisors(int('7'*i))
    if K in lis:
        print(i)
        break
else:
    print(K-1)

Submission status: Wrong Answer

Solution code:
K = int(input())

count = 0
num = 7
if K % 2 == 0:
    print(-1)
else:
    while True:
        if num % K == 0:
            count += 1
            break
        else:
            count += 1
            num = int(str(num) + "7")
print(count)

Submission status: Wrong Answer

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

if k % 2 != 0:
  if k % 5 != 0:
    while t % k != 0:
      kou += 1
      t = 10 * t + 7
    
    print(kou)

else:
  print(-1)

Submission status: Wrong Answer

Solution code:
k=int(input())
ama=[0]*(k)
now=0
for _ in range(2*k):
  now+=7*(10**_)
  if now%k==0:
    print(_+1)
    exit()
  elif ama[now%k]==0:
    ama[now%k]+=1
  else:
    print(-1)

Submission status: Wrong Answer

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

K = INT()

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

#素数判定
def is_prime(num):
	if 2 > num:
		return False
	if num in [2, 3, 5]:
		return True
	if num%2 == 0 or num%3 == 0 or num%5 == 0:
		return False
	#擬似素数(2でも3でも割り切れない数)で割っていく。(周期6)
	prime = 7
	step = 4
	while num**0.5 >= prime:
		if num%prime == 0:
			return False
		prime += step
		step = 6 - step
	return True
	
if not is_prime(K) or K == 2 or K == 5:
	print(-1)
	exit()

for i in range(2, K+1):
	t = str(i*K)
	if set(t) == {"1"}:
		print(len(t))
		break

Submission status: Wrong Answer

Solution code:
def gcd(a,b):
    if b==0:
        return a
    else:
        return gcd(b,a%b)

a=(int)(input())
flag=0

cnt=0
for i in range(1,a):
    if gcd(i,a)==1:
        cnt=cnt+1

if a%2!=0 and a%5!=0:
    for i in range(1,a):
        if cnt%i!=0:
            continue
        if a%3==0 and i%3!=0:
            continue
        if a%9==0 and i%9!=0:
            continue
        if (((int)(10**i)-1)*7) % a == 0:
            flag=1
            print(i)
            break
if flag==0:
    print(-1)

Submission status: Wrong Answer

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

INF = 10**9+7

if __name__ == "__main__":
    k = int(input())
    if k%2 == 0:
        print(-1)
        sys.exit()
    cnt = 1
    a = 7
    d = [a]
    for i in range(10**6+1):
        if d[i]%k == 0:
            print(i+1)
            sys.exit()
        b = 10*d[i]
        b+=7
        b%=k
        d.append(b)

Submission status: Wrong Answer

Solution code:
k = int(input())

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
K = int(input())

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

Submission status: Wrong Answer

Solution code:
K = int(input())

now = 7

visited = [0]*(K+10)

flg = False

for i in range(1,9999):
    tmp = now%K
    visited[tmp] += 1
    now = now*10+7

    if tmp == 0:
        flg = True
        break
    if visited[tmp] > 1 :
        flg = False
        break
    
if flg:
    print(i)
else:
    print(-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
k = int(input())
if k % 2 == 0:
  print(-1)
elif k < 7:
  print(-1)
else:
  a = 0
  count = 1
  num = "7"
  while a == 0:
    if int(num) % k == 0:
      print(count)
      a += 1
    else:
      num += "7"
      count += 1

Submission status: Wrong Answer

Solution code:
def main():
    k = int(input())
    if int(str(k)[0])%2 == 0 or k%2 == 0:
        print(-1)
    else:
        s = 7
        count = 1
        while k < 7:
            s = s*10+7
            count += 1
        temp = k
        pre = 1
        for i in range(10):
            if str(temp)[0] == '7':
                break
            pre += 1
            temp += k
        while True:
            check = str(temp)
            flag = True
            for i in range(len(check)):
                if check[i] != '7':
                    flag = False
                    break
            if flag:
                print(len(check))
                break
            temp = temp*10 + k*pre
            count += pre+1 
            
main()

Submission status: Wrong Answer

Solution code:
K = int(input())

X = []
s = len(str(K))
for i in range(s):
    X.append(7)

while True:
    Y = int("".join(map(str,X)))
    if Y % K == 0:
        print(len(X))
        break
    elif K % 2 == 0:
        print(-1)
        break
    elif K % 3 == 0:
        print(-1)
        break
    elif K % 5 == 0:
        print(-1)
        break
    elif K % 13 == 0:
        print(-1)
        break
    elif K % 17 == 0:
        print(-1)
        break
    elif K % 19 == 0:
        print(-1)
        break
    elif K % 23 == 0:
        print(-1)
        break
    elif K % 29 == 0:
        print(-1)
        break
    elif K % 31 == 0:
        print(-1)
        break
    else:
        X.append(7)

Submission status: Wrong Answer

Solution code:
#!python3.8
# -*- coding: utf-8 -*-
# abc174/abc174_c
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    K = i2n()
    if K % 7 == 0:
        K = K // 7
    x = 10 % K
    for i in range(1, K + 10):
        if pow(x, i, K) == 1:
            print(i)
            return
    else:
        print(-1)
    return

main()

Submission status: Wrong Answer

Solution code:
K = str(input())

hit = False
if int(K) % 2 == 0:
    print("-1")
else:
    a = {
        "1": 1,
        "11": 2,
        "111":3,
        "101": 4,
        "1001":6,
        "1111": 4,
        "10101": 6,
        "11111": 5,
        "100001":10,
        "1001001":9,
        "1010101":8,
        "1111111":7
    }
    for k, v in a.items():
        if k == K:
            hit = True
            print(v)
        else:
            pass
if hit == False and int(K) % 2 != 0:
    print("-1")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
k = int(input())

count = 0
ans = 1

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

Submission status: Wrong Answer

Solution code:
k = int(input())
flag = [0 for _ in range(k)]
val = 7
cnt = 1
while cnt != 10000000:
  cnt += 1
  val = ((10 * val) % k + 7) % k
  if val == 0:
    break

if cnt == 10000000:
  print(-1)
else:
  print(cnt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
k=int(input())
if k%2==0:
    print(-1)
else:
    s='7'
    flag=0
    for _ in range(20):
        if int(s)%k==0:
            flag=1
            print(len(s))
            break
        s=s+'7'
    if flag==0:
        print(k-1)

Submission status: Wrong Answer

Solution code:
from sys import stdin

K = int(stdin.readline().rstrip())
if K % 2 == 0:
  print(-1)
a_n = 7
i = 1
while True:
  if a_n < K:
    print(-1)
    break
  if a_n % K == 0:
    print(i)
    break
  else:
    i += 1
    a_n = a_n * 10 + 7