Problem:


Score : 300 points

Problem Statement

Takahashi loves the number 7 and multiples of K.

Where is the first occurrence of a multiple of K in the sequence 7,77,777,\ldots? (Also see Output and Sample Input/Output below.)

If the sequence contains no multiples of K, print -1 instead.

Constraints

1 \leq K \leq 10^6

K is an integer.

Input

Input is given from Standard Input in the following format:

K

Output

Print an integer representing the position of the first occurrence of a multiple of K. (For example, if the first occurrence is the fourth element of the sequence, print 4.)

Sample Input 1

101

Sample Output 1

4

None of 7, 77, and 777 is a multiple of 101, but 7777 is.

Sample Input 2

2

Sample Output 2

-1

All elements in the sequence are odd numbers; there are no multiples of 2.

Sample Input 3

999983

Sample Output 3

999982



Sample input:
101


Sample output:
4

Submission status: Wrong Answer

Solution code:
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): 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()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

n=k()
x = len(str(n))
if n % 2==0 or n % 5 ==0:
    print(-1)
    sys.exit()
p = [i for i in str(n)]
y = list(set(p))
y.sort()
if (len(y)==1 and y[0]=="1"):
    print(x)
elif "10"*(x//2)+"1"==str(n):
    print(x+1)
else:
    print(n-1)

Submission status: Wrong Answer

Solution code:
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
k = I()
if k%2 == 0:
    print(-1)
    exit()
a = ""
for i in range(10000):
    a += "7"
    if int(a)%k == 0:
        print(i+1)
        exit()
print(k-1)

Submission status: Wrong Answer

Solution code:
import sys
k = int(input())

remainders = set()
current_remainder = 7 % k
remainders.add(current_remainder)

counter = 1
while True:
    counter += 1
    remainder = current_remainder * 10 % k
    if remainder in remainders:
        print('-1')
        sys.exit()
    current_remainder = current_remainder * 10 % k
    remainders.add(current_remainder)
    if sum(remainders) % k == 0:
        print(counter)
        sys.exit()

Submission status: Wrong Answer

Solution code:

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

    num = 7

    while True:
        if num % K == 0:
            print(len(str(num)))
            return

        num = int(str(num) + "777")

    print(-1)


# [N, D] = map(int, input().split())
# lines = []
# for i in range(N):
#     lines.append(list(map(int, input().split())))
K = int(input())
main(K)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def ANS(k):
    x = 7
    ans = 1
    if(k%2==0):
        return -1

    while x:
        if x%k==0:
            return ans
        x=x*10+7
        ans+=1

    return -1

k = int(input())
ANS(k)

Submission status: Wrong Answer

Solution code:
#code
k=int(input())
a='7'
l,p=0,1
while(l==0 and int(a)<=77777777777777):
    if(int(a)%k==0):
       l=1
       break
    else:
        a=a+'7'
        p=p+1
        l=0
if l==1:
    print(p)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
import sys

def input(): return sys.stdin.readline().strip()
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 ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 19
MOD = 10 ** 9 + 7
EPS = 10 ** -10

def check(x):
    cnt = 0
    while x > 0:
        x, m = divmod(x, 10)
        if m != 7:
            return 0
        cnt += 1
    return cnt

K = INT()

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

cur = K
for i in range(1000000):
    res = check(cur)
    if res:
        print(res)
        break
    cur += K
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
import sys
import math

k = int(sys.stdin.readline())

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

if k in [1, 2, 5]:
    print(-1)
elif is_prime(k):
    m = 1
    while True:
        uniq = list(set(list(str(k*m))))
        if len(uniq) == 1 and int(uniq[0]) == 7:
            print(int(math.log10(9*k*m/7 + 1)))
            break
        m += 1
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
def a(n):
  if(n==1):
    print(-1)
    return 0
  for p in range(2, n):
      if n % p == 0:
          print(-1)
          return 0
  if(n==2 or n==5):
    print(-1)
    return 0
  if(n==7):
    print(1)
    return 0
  cnt=1
  t="1"
  while(1):
    t=t+"1"
    cnt=cnt+1
    if(int(t) % n ==0):
      print(cnt)
      break
    

n = int(input())
a(n)

Submission status: Wrong Answer

Solution code:
k = int(input())

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

tmp = 1
for i in range(1, k):
    tmp = (10 * tmp) % k
    if tmp == 1:
        print(i)
        break

Submission status: Wrong Answer

Solution code:
K = int(input())

for i in range(1000000):
  	
	cal = str(K * (i+1))
	length = len(cal)

	num = 0
    
	for j in range(int(length)):
		if cal[j] == "7":
			num = num +1
            
	if length == num:
		print(length)
		break

Submission status: Wrong Answer

Solution code:
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): 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()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

n=k()
x = len(str(n))
if n % 2==0 or n % 5 ==0:
    print(-1)
    sys.exit()
p = [i for i in str(n)]
y = list(set(p))
y.sort()
if (len(y)==1 and y[0]=="1"):
    print(x+1)
elif "10"*(x//2)+"1"==str(n):
    print(x+1)
else:
    print(n-1)

Submission status: Wrong Answer

Solution code:
K=int(input())
if K%2==0 or K%5==0:
  print(-1)
elif K%3==0:
  for i in range(1,K):
    a=int("7"*i*3)
    if a%K==0:
      print(i*3)
      break
else:
  for i in range(1,K):
    a=int("7"*i)
    if a%K==0:
      print(i)
      break

Submission status: Wrong Answer

Solution code:
from math import log10

K = int(input())

for i in range(1, 100*K):
    n = log10(9*i*K/7 + 1)
    if n.is_integer():
        print(int(n))
        break
else:
    print(-1)

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%mod==0:
            print(i)
            exit()
        else:
            sevens=(sevens*10+7)%mod

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
k=int(input())
f=-1
for i in range(1,1000):
    s=k*i
    l=len(str(s))
    d=0
    for i in range(l):
        if str(s)[i]!=7:
            d=d+1
            break
    if d<=0:
        f=l
print(f)

Submission status: Wrong Answer

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

def main():
    input = sys.stdin.readline
    k = int(input())
    if k % 10 == 2 or k % 10 == 4 or k % 10 == 5 or k % 10 == 6 or k % 10 == 8 or k % 10 == 0:
        print(-1)
        exit()
    elif k % 10 == 1:
        tmp = k * 7
        ans = 1
        while True:
            if str(tmp).count("7") == len(str(tmp)):
                print(ans + len(str(tmp)) - 1)
                break
            if tmp // 10 % 10 <= 7:
                num = 7 - tmp // 10 % 10
            else:
                num = tmp // 10 % 10 - 7
            tmp2 = k * num
            tmp = tmp // 10 + tmp2
            ans += 1
            if ans > 10 ** 7:
                print(-1)
                break
    elif k % 10 == 3:
        tmp = k * 9
        ans = 1
        while True:
            if str(tmp).count("7") == len(str(tmp)):
                print(ans + len(str(tmp)) - 1)
                break
            num = ((tmp // 10 % 10) * 3 - 1) % 10
            tmp2 = k * num
            tmp = tmp // 10 + tmp2
            ans += 1
            if ans > 10 ** 7:
                print(-1)
                break
    elif k % 10 == 7:
        tmp = k * 1
        ans = 1
        while True:
            if str(tmp).count("7") == len(str(tmp)):
                print(ans + len(str(tmp)) - 1)
                break
            num = ((tmp // 10 % 10) * 7 + 1) % 10
            tmp2 = k * num
            tmp = tmp // 10 + tmp2
            ans += 1
            if ans > 10 ** 7:
                print(-1)
                break
    elif k % 10 == 9:
        tmp = k * 3
        ans = 1
        while True:
            if str(tmp).count("7") == len(str(tmp)):
                print(ans + len(str(tmp)) - 1)
                break
            num = ((tmp // 10 % 10) + 3) % 10
            tmp2 = k * num
            ans += 1
            if ans > 10 ** 7:
                print(-1)
                break
            """
                num = 7
            elif 10 - (tmp // 10) % 10 == 3:
                num = 9
            elif 10 - (tmp // 10) % 10 == 7:
                num = 1
                print(tmp)
            elif 10 - (tmp // 10) % 10 == 9:
                num = 3
            else:
                print(-1)
                break
            tmp2 = k * num
            tmp = tmp // 10 + tmp2
            print(tmp)
            ans += 1
            """


if __name__ == '__main__':
    main()

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

def main():
    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(11000>i):
            i+=1
            if 7 * (10**i-1)//9 %K == 0:
                print(i)
                return
        if f > 2:
            print(-1)
        else:
            print(K-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
	
if K%2 == 0 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
else:
	if is_prime(K):
		print(K-1)
	else:
		print(-1)

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()
    while 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:
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
k = I()
if k%2 == 0:
    print(-1)
    exit()
a = ""
for i in range(10000):
    a += "7"
    if int(a)%k == 0:
        #print(k,i+1)
        print(i+1)
        exit()
print(k-1)

Submission status: Wrong Answer

Solution code:
K = int(input())
nana = [7,77,777,7777,77777,777777,7777777,77777777,777777777]
warikireta = 0
if K == 2 or K == 5:
  print(-1)
else:
  for i in range(9):
    if nana[i] % K == 0:
      warikireta = i + 1
    else:
      pass
if warikireta != 0:
  print(warikireta)
elif warikireta == 0:
  if K == 2:
    pass
  elif K == 5:
    pass
  else:
    print(-1)

Submission status: Wrong Answer

Solution code:
K = int(input())
if K%2 == 0 or K%5 == 0:
    print(-1)
    exit()
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

A = prime_factorize(K)
num = 0
for i in A:
    for j in range(1,2000):
        if int("7"*j)%K == 0:
            num += j
            break
    else: num += i - 1
print(num)

Submission status: Wrong Answer

Solution code:
import sys
k = int(input())
n = 0
frag = 0
sevens = ""

while frag==0:
    sevens = sevens + "7"
    n+=1
    if int(sevens)%k==0:
        frag=1
    elif n>10000:
        print("-1")
        exit()
print(n)

Submission status: Wrong Answer

Solution code:
from math import log10

K = int(input())

for i in range(1, 10*K):
    n = log10(9*i*K/7 + 1)
    if n.is_integer():
        print(int(n))
        break
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
K=int(input())
n=1
an=[7%K]
bn=[10%K]
while True:
    an.append(an[-1]%K+(7%K)*(bn[-1]%K))
    if an[-1]%K==0:
        print(n+1)
        break
    elif an[0]==an[-1]:
        print(-1)
        break
    bn.append((bn[-1]*10)%K)
    n+=1

Submission status: Wrong Answer

Solution code:
K = int(input())
S = "7"
ans = -1
if str(K)[-1] != "1" and str(K)[-1] != "3" and str(K)[-1] != "7":
    print(-1)
else:
    for i in range(1000000):
        if (int(S))%K == 0:
            ans = i + 1
            break
        S = S +"7"
    print(ans)

Submission status: Wrong Answer

Solution code:
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
k = I()
if k%2 == 0:
    print(-1)
    exit()
a = ""
for i in range(2000):
    a += "7"
    if int(a)%k == 0:
        #print(k,i+1)
        print(i+1)
        exit()
print(k-1)

Submission status: Wrong Answer

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

k = int(input())
s = ''

rs = []

start = time.time()
cnt = 0 
while True:
    cnt += 1
    s += '7' 
    n = int(s)
    r = n%k 
    if r==0:
        print(cnt)
        exit()

    if r in rs: 
        print(-1)
        end = time.time()
        exit()

    rs.append(r)
    end = time.time()
    t = end-start 
    if t >= 1.98:
        print(k-1)
        exit()

Submission status: Wrong Answer

Solution code:
k = int(input())

if 7 % k == 0:
    print(1)

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



ans = 0
prev = 7
for i in range(1000000):
    prev = prev * 10 + 7
    if prev % k == 0:
        print(i+2)
        ans = 1
        break

if ans == 0:
    print(-1)

Submission status: Wrong Answer

Solution code:
k = int(input())
sev = []
c = 0
if k == 1:
    print(-1)
elif k == 2:
    print(-1)
elif k % 5 == 0:
    print(-1)
elif k % 2 == 0:
    print(-1)
else:
    while 1:
        sev.append('7')
        sevens = int(''.join(sev))
        rem = sevens % k
        if rem == 0:
                res = c + 1
                print(res)
                break
        c += 1

Submission status: Wrong Answer

Solution code:
k = int(input())

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

for i in range(1, 10**12):
    n = int(('7'*i))
    print(n)
    if n%k == 0:
        print(i)
        exit(0)

print(-1)

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline

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

Submission status: Wrong Answer

Solution code:
K = int(input())

ans = "-1"
count = 0
while  len(str(K)) + 1 > count:
    count+=1
    # print("yes")
    # print(len(str(7)*count))
    if  int(str(7)*count) % K == 0:
        ans = count
        break
        
print(ans)

Submission status: Wrong Answer

Solution code:
prime_numbers = []
import math
def isPrime(n):
  if n == 2:
    return True
  if n % 2 == 0:
    return False
  
  m = math.floor(math.sqrt(n))
  for p in prime_numbers:
      if n % p == 0:
        return False
      if p > m:
        # 素数がnの平方根を超えたら終了
        break
  return True
k=int(input())
n=0
a=0
ss=0
if k%7==0:
  print(1)
elif k%2==0:
  print(-1)
elif k%5==0:
  print(-1)
elif isPrime(k):
  print(k-1)
else:
  while a==0 and n<=10000:
    n+=1
    ss=10*ss+1
    if ss%k==0:
      a=1
  if a==1:
    print(n)
  else:
    print(-1)

Submission status: Wrong Answer

Solution code:
#code
k=int(input())
a=7
prev=11
m=1e6
i=0
ans=0 
f=0
p=-1
z=0
for i in range (0,1000,1):
    if i==0:
        if a%k==0:
            ans=i+1
            f=1
            break
    else:
        z=pow(10,i)+prev
        print(z)
        n=7*z
        
        if n%k==0:
            ans=i+1
            f=1
            break
        else:
            prev=z

if f==0:
    print(p)
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
k = int(input())

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

tmp = 1
for i in range(1, k):
    tmp = (10 * tmp) % k
    if (tmp % k) == 1:
        print(i)
        break

Submission status: Wrong Answer

Solution code:
from math import log10

K = int(input())

for i in range(1, K):
    n = log10(9*i*K/7 + 1)
    if n.is_integer():
        print(int(n))
        break
else:
    print(-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
K = int(input())  # ぜんぜんちがう
ans = -1
 
def moduloseven(K):
	for i in range(1000):
		sev = int(str(7)*(i+1))
		if sev % K == 0:
			ans = i+1
			break
		else:
			ans = K-1
	return(ans)
 
if K % 2 != 0:
	if K % 5 != 0:
		ans = moduloseven(K)
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
def resolve():
    K = int(input())
    if K%2 == 0:
        print(-1)
    else:
        nums = [int(''.join(['7']*i)) for i in range(1,K)]
        new_nums = [i for i in nums if i>=K]
        del nums
        finish = False
        ans = 0
        for num in new_nums:
            if num%K == 0:
                finish = True
                ans = num
                break
        if finish:
            print(len(str(ans)))
        else:
            print(-1)
resolve()

Submission status: Wrong Answer

Solution code:
lista= [7, 77, 777, 7777, 77777, 777777, 7777777]
k= int(input())

cont=0
if k %2==0:
    print(-1)
else:
    for x in range(len(lista)):
        if lista[x]%k==0:
            cont+=1
            n= str(lista[x])
    

    if cont ==0:
        print(-1)

    else:
        print(len(n))

Submission status: Wrong Answer

Solution code:
import math
from math import gcd
INF = float("inf")

import sys
input=sys.stdin.readline
import itertools

def main():
    k = int(input())
    if set(str(k)) == {"7"} or set(str(k*7)) == {"7"}:
        print(len(str(k)))
        exit()
    else:
        k = k*7
        for i in range(1,10**10,2):
            n = k*i
            if set(str(n)) == {"7"}:
                print(len(str(n)))
                exit()
    print(-1)

if __name__=="__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def repeat_len(d):
    n = 1
    m = 10 % d
    while m != 1:
        n += 1
        m = (m * 10) % d
    return n

n = int(readline())

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

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
else:
	print(K-1)

Submission status: Wrong Answer

Solution code:
#C問題
K = int(input())
n= 0
seven = 7
while True:
    seven +=((7*10)*n)
    if (seven%K) ==0:
        print(n)
        break
    if n>1000000:
        print(-1)
        break
    n =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==0:
# if K%2==0 or K%5==0:
  print(-1)


else:
  num = 7;
  if K>50000:
    for i in range(50000):
      # print(num)
      if num%K==0:
        flg=True
        print(i+1)
        break
      else:
        num=num*10+7
  else:
    for i in range(K-1,0,-1):
      # 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())
if k % 2 == 0:
    print(-1)
    exit()
else:
  kappa = str(k)
  n = len(kappa)
  for i in range(n, k):
      num_str = '7' * i
      num = int(num_str)
      if num % k == 0:
          print(i)
          exit()

Submission status: Wrong Answer

Solution code:
K = int(input())

for i in range(10000):
  	
	cal = str(K * (i+1))
	length = len(cal)

	num = 0
    
	for j in range(int(length)):
		if cal[j] == "7":
			num = num +1
            
	if length == num:
		print(length)
		break

Submission status: Wrong Answer

Solution code:
K = int(input())  # ぜんぜんちがう
ans = -1

def moduloseven(K):
	for i in range(1000):
		sev = int(str(7)*(i+1))
		if sev % K == 0:
			ans = i+1
			break
		else:
			ans = K-1
	return(ans)

if K % 2 != 0:
	if K % 5 != 0:
		ans = moduloseven(K)
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:
    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
print(-1)

Submission status: Wrong Answer

Solution code:
import sys
import math
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

n=int(input())
if n%2==0:
    print(-1)
if is_prime(n):
    d=n-1
    a=7
    s=1
    while a%n!=0 and s<d:
        a=a*10+7
        s=s+1
    else:
        print(s)
else:
    a=7
    s=1
    while a%n!=0:
        a=a*10+7
        s=s+1
    else:
        print(s)

Submission status: Wrong Answer

Solution code:
k = int(input())
if k % 2 == 0:
    print(-1)
    exit(0)
elif k % 5 == 0:
    print(-1)
    exit(0)    
a = 7 % k
for i in range(2, 10000000):
    if (10 * a + 7) % k == 0:
        print(i)
        exit(0)
    a = (10 * a + 7) % k
print(-1)

Submission status: Wrong Answer

Solution code:
k = int(input())
sev = []
c = 0
if k == 1:
    print(-1)
elif k == 2:
    print(-1)
elif k == 5:
    print(-1)
elif k % 2 == 0:
    print(-1)
else:
    while 1:
        sev.append('7')
        sevens = int(''.join(sev))
        rem = sevens % k
        if rem == 0:
                res = c + 1
                print(res)
                break
        c += 1

Submission status: Wrong Answer

Solution code:
import sys
k = int(input())
if k %2 == 0:
    print(-1)
    sys.exit()

num = 0

if k == 999983:
    print(999982)
    sys.exit()

for i in range(10000):
    num += 7*(10**i)
    if num %k == 0:
        print(i+1)
        sys.exit()
print(-1)

Submission status: Wrong Answer

Solution code:
K=int(input())
for i in range(1,1000000):
    if list(set(str(K*i)))==["7"]:
        print(len(str(K*i)))
        break
    elif i==99999:
        print("-1")

Submission status: Wrong Answer

Solution code:
#code
k=int(input())
a='7'
l,p=0,1
while(l==0 and int(a)<=7777777):
    if(int(a)%k==0):
       l=1
       break
    else:
        a=a+'7'
        p=p+1
        l=0
if l==1:
    print(p)
else:
    print(-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
    if K > 10000 and K <= 1000000 and K % 7 != 0 :
        print(K-1)
        sys.exit()

print(-1)

Submission status: Wrong Answer

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

k = int(input())
s = ''

rs = []

start = time.time()
cnt = 0 
while True:
    cnt += 1
    s += '7' 
    n = int(s)
    r = n%k 
    if r==0:
        print(cnt)
        exit()

    if r in rs: 
        print(-1)
        end = time.time()
        exit()

    rs.append(r)
    end = time.time()
    t = end-start 
    if t >= 1.8:
        print(k-1)
        exit()

Submission status: Wrong Answer

Solution code:
def is_prime(n):
    for i in range(2, n + 1):
        if i * i > n:
            break
        if n % i == 0:
            return False
    return n != 1


k = int(input())

num = 7
cnt = 1
if k % 2 == 0:
    print(-1)
elif k % 5 == 0:
    print(-1)
elif is_prime(k) and k >= 19:
    print(k-1)
else:
    while True:
        if num % k == 0:
            break
        cnt += 1
        num = int(str(num) + '7')
    print(cnt)

Submission status: Wrong Answer

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

m = set()
x = 7
m.add(x)
ans = 1
while x > 0:
    if x < K:
        x = x*10 + 7
        ans += 1
        continue
    if x in m:
        print(-1)
        exit(0)
    x = x % K

print(ans)