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 sys
K=int(input())


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

if K %7==0:
    for i in range(1,10**6,2):
        kazu=K*i
        st1=str(kazu)
        lis1=''.join(st1.split("7"))
        if lis1=="":
            print(len(st1))
            sys.exit()
else:
    for i in range(7,10**7,7):
        kazu=K*i
        st1=str(kazu)
        lis1=''.join(st1.split("7"))
        if lis1=="":
            print(len(st1))
            sys.exit()
print(-1)

Submission status: Wrong Answer

Solution code:
k_len = input()
k = int(k_len)
number = len(k_len)
Seq = 7

while True:

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

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

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()
    a = 7
    p = len(str(k)) + 1
    for i in range(p):
        if a%k == 0:
            print(i+1)
            sys.exit()
        a*=10
        a+=7
    print(k-1)

Submission status: Wrong Answer

Solution code:
import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(500000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

k=int(input())

if k%2==0 or k%5==0:
    print(-1)
else:
    if k%7==0:
        k//=7
    tmp=1
    cnt=1
    while (tmp*10-1)%k:
        tmp*=10
        tmp%=k
        cnt+=1
    print(cnt)

Submission status: Wrong Answer

Solution code:
def solution(K: int) -> int:
    ans: int = 0
    x: int = 7
    while True:
        print(x)
        print()
        ans += 1
        # K が偶数の時
        if K % 2 == 0:
            return -1
        # x が K より小さい時
        if x < int(K):
            x: int = int(str(x) + str(7))
            continue
        if x % K == 0:
            return ans
        x: int = int(str(x) + str(7))
    return ans


K: int = int(input())

print(solution(K))

Submission status: Wrong Answer

Solution code:
#from math import *
from collections import *
from random import *
from bisect import *
import sys
input=sys.stdin.readline
def lis():
    return list(map(int,input().split()))
def ma():
    return map(int,input().split())
def inp():
    return int(input())
n=inp()
if(n%2==0 or n%5==0):
    print(-1)
    exit(0)
co=1
if(7%n==0):
    print(1)
    exit(0)
while(1):
    gp=10*(pow(10,co,n)-1)
    gp=gp%n
    gp=gp*pow(9,n-2,n)
    gp+=1
    gp=7*gp
    gp=gp%n
    if(gp%n==0):
        break
    co+=1
print(co+1)

Submission status: Wrong Answer

Solution code:
#-------------
K = int(input())
#-------------
seven = 0
nana = []
for i in range(10000):
  seven += 7 * (10**i)
  nana.append(seven)

cnt = 1
counter = []
for i in range(10000):
  if nana[i]%K != 0:
    cnt +=1
  if nana[i]%K == 0:
    counter.append(cnt)
    
if counter == []:
  print("-1")
else:
  print(min(counter))

Submission status: Wrong Answer

Solution code:
K = int(input())
ch = False
for i in range(1, 10):
  check = str(K * i)
  if int(check[-1]) == 7:
    ch = True
    break
  else:
    continue
if ch == False:
  print(-1)
  exit()
if K % 7 == 0:
  print(1)
  exit()
counter = 0
k = 7
a = 10
n = 0
ok = False
while True:
  n += 1
  counter += 1
  if k % K == 0:
    print(counter)
    exit()
  s = a ** n
  k += 7 * s

Submission status: Wrong Answer

Solution code:
k = int(input())
cnt = 0
if k % 2 == 0:
    print("-1")
else:
    n = ""
    while True:
        cnt += 1
        n = n + "7"
        print(n, k)
        print(int(n) % k)
        if int(n) % k == 0:
            break
        else:
            pass
    print(cnt)

Submission status: Wrong Answer

Solution code:
k=int(input())
if k%2 == 0 or k%5 == 0:
  print(-1)
  exit()
s = ''
for i in range(100):
  s += '7'
  if int(s) % k == 0:
    print(i+1)
    exit()
#nの素数判定
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
if is_prime(k):
  print(k-1)
  exit()
print(-1)

Submission status: Wrong Answer

Solution code:
K = int(input())

if K % 2 == 0 or K % 5 == 0:
    print(-1)
elif K % 7 == 0:
    K = K // 7
else:
    j = 1
    while True:
        if pow(10, j, K*9) == 1:
            print(j)
            break
        else:
            j += 1

Submission status: Wrong Answer

Solution code:
K = int(input())

def get_primes(N):
    P = []
    M = N
    k_max = int(N**0.5)
    for k in range(2,k_max+1):
        is_next = False
        while not is_next:
            if M % k == 0:
                P.append(k)
                M = M // k
            else:
                is_next = True
    if M != 1:
        P.append(M)
    return P


def check(l):
    return int(l*"7") % K == 0
def check2(l):
    def check2_(K):
        return (K-1) % l == 0
    return check2_
def get_changes(N):
    targets = []
    for p in get_primes(N):
        targets.extend([ i*p for i in range(1,N//p+1) ])
    targets = sorted(list(set(targets)))
    return targets

K_prime = get_primes(K)

num_3 = sum(map(lambda x:x==3, K_prime))
K_prime_ex = K_prime[num_3:]

if 2 in K_prime or 5 in K_prime:
    print(-1)
elif K == 7:
    print(1)
else:
    target_primes = sorted(list(set(K_prime_ex)))
    if len(target_primes) == 0:
        print(K)
    else:
        ##for l in range(2,K+1):
        targets = []
        for p_ in target_primes:
            targets.extend(get_changes(p_-1))
        targets = sorted(list(set(targets)))

        #print(targets)


        for l in targets:
            if num_3 > 0 and l % num_3 != 0:
                continue
            #check_ = check2(l)
            #print(l, list(map(check_, target_primes)))
            #if any(map(check_, target_primes)) and check(l):
            if check(l):
                print(l)
                break

Submission status: Wrong Answer

Solution code:
#from math import *
from collections import *
from random import *
from bisect import *
import sys
input=sys.stdin.readline
def lis():
    return list(map(int,input().split()))
def ma():
    return map(int,input().split())
def inp():
    return int(input())
n=inp()
if(n%2==0):
    print(-1)
    exit(0)
co=1
if(7%n==0):
    print(1)
    exit(0)
while(1):
    if(co>1000000):
        co=-2
        break
    gp=10*(pow(10,co,n)-1)
    gp=gp%n
    gp=gp*pow(9,n-2,n)
    gp+=1
    gp=7*gp
    gp=gp%n
    if(gp%n==0):
        break
    co+=1
print(co+1)

Submission status: Wrong Answer

Solution code:
K = int(input())

if K % 2 == 0 or K % 5 == 0:  print(-1)
else:
    p = 0
    for i in range(K):
        p = ((p * 10) % K + 1) % K
        if p == 0:  
            print(i + 1)
            break

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%2 == 0 or K%5 == 0:
    print(-1)
    exit()
m = 1
for i in range(1,40000):
    m *= 10
    if (m-1)*7%K == 0:
        print(i)
        exit()
print(K-1)

Submission status: Wrong Answer

Solution code:
N = int(input())
st = '7'
if N % 2:
    count = 1
    while True:
        if count % 1000 == 0:
            print(count / 1000)
        test_n = int(st*count)
        if test_n % N:
            pass
        else:
            print(count)
            break

        count += 1

else:
    print(-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#from math import *
from collections import *
from random import *
from bisect import *
import sys
input=sys.stdin.readline
def lis():
    return list(map(int,input().split()))
def ma():
    return map(int,input().split())
def inp():
    return int(input())
n=inp()
if(n%2==0):
    print(-1)
    exit(0)
co=1
if(7%n==0):
    print(1)
    exit(0)
while(1):
    if(co>1000000):
        co=-1
        break
    gp=10*(pow(10,co,n)-1)
    gp=gp%n
    gp=gp*pow(9,n-2,n)
    gp+=1
    gp=7*gp
    gp=gp%n
    if(gp%n==0):
        break
    co+=1
print(co+1)

Submission status: Wrong Answer

Solution code:
import math
K=int(input())
P=0
for i in range(10000000):
    M=math.log10(K*9*(2*i+1)+1)
    if M-int(M)==0:
        print(int(M))
        P=1
        break
if P==0:
  print(-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# C - Repsept
def main():
    k = input()

    if int(k) % 2 == 0:
        print(-1)
        exit()
    else:
        for i in range(len(k), int(int(k)**0.5)):
            li7 = '7'*i
            if int(li7) % int(k) == 0:
                print(i)
                exit()
        
    print(int(k)-1)


if __name__ ==  "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def createlist():
    max_range = 10 ** 6

    flag = True

    while True:
        if len(list_7) == 0:
            list_7.append(7)
        else:
            last_element = list_7[-1]
            new_element = last_element * 10 + 7
            
            if new_element > max_range:
                break
            else:
                list_7.append(new_element)


# create a list

list_7 = []

createlist()

k = int(input())

length = len(list_7)
i = 0

found = False
while i < length:
    if (list_7[i] % k) == 0:
        print(i + 1)
        found = True
        break

    i += 1

if not found:
    print('-1')

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 func(n):
	cnt = 0
	while(n):
		if n%10!=7:
			return -1 
		n = n//10
		cnt+=1
	return cnt



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 

pk = func(n)
if pk!=-1:
	print(pk)
else:
	print(repUnitValue(n))

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:
s = int(input()) 
 
L=[7,
77,
777,
7777,
77777,
777777,
7777777,
77777777,
777777777,
7777777777,
77777777777,
777777777777,
7777777777777,
77777777777777,
777777777777777,
7777777777777777,
77777777777777777]
 
ans=0
for i,a in enumerate(L):
    if a % s==0:
        ans=i+1
        break
    
else :
    ans=-1
print(ans)

Submission status: Wrong Answer

Solution code:
K=input()
print(-1)

Submission status: Wrong Answer

Solution code:
import math
k = int(input())
count = 1
seven = 7
if k%2 == 0:
    print(-1)
else:
    while True:
        if(seven%k==0):
            print(count)
            break
        else:
            seven += 7* (10**count)
            print (count)
            count+=1

Submission status: Wrong Answer

Solution code:
k = int(input())

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#!/usr/local/bin/python3
# coding: utf-8
import numpy as np

kita = int(input())
seven = ""
i = 0
while True:
    i += 1

    if kita % 2 == 0:
        print(-1)
        break
    if kita % 5 == 0:
        print(-1)
        break

    seven += "7"
    if int(seven) > kita: 
        if int(seven) % kita == 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(-1)

Submission status: Wrong Answer

Solution code:
k = int(input())
if k%2==0 or k%5==0:
    print(-1)
    exit()
    
def so(n):
  for i in range(2,n):
    if n%i==0:
      return False
  else:
    return True
    
t = 10**4
if k%7==0:
  k//= 7
l = len(str(k))
s = int(str(1)*l)
ind = l
while t!=0 :
    if s%k==0:
        print(ind)
        exit()
    else:
        s = s*10+1
        ind += 1
    t -=1
if so(k)==True:
  print(k-1)
  exit()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
K = int(input())

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

elif (K%10) % 5 == 0:
    pass
    #print(-1)
else:
    num = 7
    for i in range(1000000):
        if num % K == 0:
            print(str(i+1))
            break
        num = num *10 + 7
    else:
        print(-1)

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)
elif K == 1: print(1)
elif K % 3 == 0: print(K)
else:
    for i in range(1,K):
        if ((pow(10,(i + 1),K) - 1) / 9) % K  == 0:
            print(i + 1)
            break

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
K = int(input())
seven = 7
count = 0

if(K % 2 == 0 or K % 5 == 0):
    print(-1)
else:
    while(seven % K != 0):
        count += 1
        seven += 7 * (10 ** count)
        print(count)

    if(count >= 1): 
        print(count + 1)

Submission status: Wrong Answer

Solution code:
K = int(input())

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

X = 7
count = 1

while(1):
    if X % K == 0:
        print(count)
        exit()
    X = X*10 + 7
    count += 1
    print(count)
    print(X)

print(-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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

if ans:
    print(min(ans))
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
k=int(input())
x=[]
for i in range(1,100000):
  t='1'*i
  t=int(t)
  if t%k==0:
    print(i)
    exit()
  else:
    if t%k in x:
      print('-1')
      exit()
    x+=[t%k]

Submission status: Wrong Answer

Solution code:
def Repsept():
    
    num = int(input())

    mod_value = 1

    count = 1

    if num % 2 != 0:

        while mod_value != 0:
            value = 7*(pow(10, count)-1)/9
            
            mod_value = value % num

            if mod_value != 0:
                count = count + 1

                if count >= 300:
                    break

        if count < 300:
            print(count)
        
        else:
            print(num-1)
        
    else:
    
        print(-1)

if __name__ == '__main__':
    Repsept()

Submission status: Wrong Answer

Solution code:
k=int(input())

if k%2==0 and k<7:
  print(-1)
  
else:
  if k<=10**4:
    for i in range(1,k+1):
      t=int('7'*i)
      #print(t)
      if t%k==0:
        flag=i
        exit()
  else:
    for i in range(k,10**4-1,-1):
      t=int('7'*i)
      
      #print(t)
      if t%k==0:
        print(i)
        exit()

Submission status: Wrong Answer

Solution code:
n =int(input())
if n%2==0:
    print(-1)
else:
    ans =1
    start = 7
    while True:
        start = ((start%n*10%n)+7)%n
        #start = start%n
        #print(start)
        if start ==0:
            ans+=1
            print(ans)
            break
        ans+=1

Submission status: Wrong Answer

Solution code:
k = int(input())

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

Submission status: Wrong Answer

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

a = 0
for i in range(K):
    a = 7 * 10**(i) + a
    if a % K == 0:

      print(i)
      break

    else:
      continue

Submission status: Wrong Answer

Solution code:
K=int(input())

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

ans=1

while (((10**(ans+1) -1)//9))*7%K !=0:
    ans+=1

print(ans)

Submission status: Wrong Answer

Solution code:
K = input()
N = 10 **2
x = 7
y = []
for i in range(1, N):
  y.append(x)
  x += 7 * 10 **i


for i in range(N -1):
  if y[i] % int(K) == 0:
    print(i+1)
  elif i == N-2:
    print('-1')

Submission status: Wrong Answer

Solution code:
a = "7"
k = int(input())
ans = 1
arr = 10**3
while ans < arr:
    if k%2 == 0:
        ans = arr
        break
    if int(a) < k:
        ans += 1
        a += "7"
        continue
    if int(a)%k == 0:
        break
    ans += 1
    a += "7"

if ans == arr:
    print(-1)
else:
    print(ans)

Submission status: Wrong Answer

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

    if K % 2 == 0:
        return -1
    elif K % 5 == 0:
        return -1

    an_min = 7
    an_max = int("7" * K)

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

        an_min = an_min * 10 + 7

        if an_max % K == 0:
            return len(str(an_max))

        an_max = an_max // 10

if __name__ == "__main__":
    answer = main()
    print(answer)

Submission status: Wrong Answer

Solution code:
k=int(input())
ans=1
n=7
p=7%k
if k%2==0:
  ans=-1
else:
  while n!=0:
    n=(n*(10%k)+7%k)%k
    if n==p:
      ans=-1
      break
    ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
K = int(input())
if K%2 == 0:
  print(-1)
  exit()
num = 0
for i in range(10**4+1):
  num *= 100
  num += 77
  if num%K == 0:
    print(len(str(num)))
    exit()
print(K-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
k=int(input())
ans=1
n=7
p=7%k
if k%2==0:
  ans=-1
else:
  while n==0:
    n=(n*(10%k)+7%k)%k
    if n==p:
      ans=-1
      break
    ans+=1
print(ans)

Submission status: Wrong Answer

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

  
print(-1)

Submission status: Wrong Answer

Solution code:
a = "7"
k = int(input())
ans = 1
while ans < 10**2:
    if k%2 == 0:
        ans = 10**2
        break
    if int(a) < k:
        ans += 1
        a += "7"
        continue
    if int(a)%k == 0:
        break
    ans += 1
    a += "7"

if ans == 10**2:
    print(-1)
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
if n % 2 == 0 or n % 5 == 0:
    print(-1)
else:
    k = n - 1
    while k % 5 == 0:
        k = k // 5
    print(k)

Submission status: Wrong Answer

Solution code:
k=int(input())

sevens="7"
if k%2==0:
    print(-1)
else:
    for i in range(10000):
        if int(sevens)%k==0:
            print(i+1)
            exit()
        else:
            sevens+="7"
    else:
        if k<=i:
            print(-1)
        else:
            print(k-1)

Submission status: Wrong Answer

Solution code:
import sys
x = int(input())
if x%2 == 0:
    print(-1)
    sys.exit()
y = 7
i = 1
while y%x != 0:
    if i == 100:
        print(-1)
        sys.exit
    i = i + 1
    y = y*10 + 7
print(i)

Submission status: Wrong Answer

Solution code:
import sys
a=int(input())
b=7
for i in range(a-2):
  b=b*10+7
if b%a==0:
  print(a-1)
  sys.exit()
elif b*10+7%a==0:
  print(a)
  sys.exit()
else:
  print(-1)

Submission status: Wrong Answer

Solution code:
k = int(input())
s = "7"

flag = 0
while int(s) <= 10**6:
  if(int(s) % k == 0):
    flag = 1
    break
  else:
    s += "7"

print(len(s)) if flag else print(-1)

Submission status: Wrong Answer

Solution code:
#!/usr/local/bin/python3
# coding: utf-8
import numpy as np

kita = int(input())
seven = ""
i = 0
while True:
    i += 1

    if kita % 2 == 0:
        print(-1)
        break
    if kita % 2 == 0:
        print(-1)
        break

    seven += "7"
    if int(seven) > kita: 
        if int(seven) % kita == 0:
            print(i)
            break

Submission status: Wrong Answer

Solution code:
def main():

    k = input()
    K = int(k)
    if K % 2 == 0:
        print('-1')
    else:
        for i in range(1, 10 ** 3 * len(k) + 1):
            target = int('1' * i) * 7
            if target % K == 0:
                print(i)
                break
        else:
            print(K - 1)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
K = int(input())
if K%2 == 0:
  print(-1)
  exit()
num = 0
for i in range(int(K**0.5)+1):
  num *= 100
  num += 77
  if num%K == 0:
    print(len(str(num)))
    exit()
print(K-1)

Submission status: Wrong Answer

Solution code:
import sys
x = int(input())
if x%2 == 0:
    print(-1)
    sys.exit()
y = 7
i = 1
while y%x != 0:
    if i == 10000:
        print(-1)
        sys.exit
    i = i + 1
    y = y*10 + 7
print(i)

Submission status: Wrong Answer

Solution code:
import time
start = time.time()
k = int(input())
ans = 0
if k % 2 == 0:
  print("-1")
  quit()
for i in range(10**6):
  if time.time()-start > 1.99:
    print("-1")
    quit
  ans += (10**i)*7
  if ans % k == 0:
    print(i)
    break
else:
  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:
  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:
# C - Repsept
def main():
    k = input()

    if int(k) % 2 == 0:
        print(-1)
    else:
        for i in range(len(k), int(int(k)**0.5)):
            li7 = '7'*i
            if int(li7) % int(k) == 0:
                print(i)
                exit()
        else:
            print(int(k)-1)


if __name__ ==  "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
K = int(input())
seven = 7
MOD7 = 7 % K
MOD70 = 70 % K
MOD77 = MOD7 + MOD70
if K % 2 == 0:
    print(-1)
elif MOD7 == 0:
    print(1)
else:
    for i in range(1,K):
        if MOD77 % K == 0:
            break
        MOD70 = (MOD70 * 10) % K
        MOD77 += MOD70
        MOD77 = MOD77 % K
    print(i+1)

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 

if n==7:
	print(1)
else:
	print(repUnitValue(n))

Submission status: Wrong Answer

Solution code:
k=int(input())

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

if k%7==0:
  k//=7

o=0
m=1
if k==1:
  print(1)
  exit()

for i in range(1,k):
  m*=10
  o+=m%k
  o%=k
  if o==0:
    print(i)
    exit()

Submission status: Wrong Answer

Solution code:
def main():

    k = input()
    K = int(k)
    if K % 2 == 0:
        print('-1')
    for i in range(1, 10 ** 3 * len(k) + 1):
        target = int('1' * i) * 7
        if target % K == 0:
            print(i)
            break
    else:
        print(K - 1)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from math import gcd


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 = {2: -1, 3: 1, 5: -1, 7: 1}
if k in ans:
    print(ans[k])
if k % 7 == 0:
    k //= 7

p = set(make_divisors(k - 1))
num = 7
for i in range(1, k):
    if int('7' * i) % k == 0:
        print(i)
        break

Submission status: Wrong Answer

Solution code:
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

k = ni()
k = k//7 if k%7==0 else k

#約数列挙
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

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

n = make_divisors(k-1)
n.sort()

for i in n:
    if i+1 == k:
        print(i)
        exit()
    if int('1'*i) % k == 0:
        print(i)
        exit()

print(-1)

Submission status: Wrong Answer

Solution code:
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

K = int(readline())

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

Submission status: Wrong Answer

Solution code:
k = int(input())

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

s = 7
cnt = 1
while cnt <= 10**2:
    if s % k == 0:
        print(cnt)
        exit()
    s += 7 * 10**cnt
    cnt += 1

print(k-1)
exit()

Submission status: Wrong Answer

Solution code:
K=input()
kl=len(K)
K=int(K)
a=7
for i in range(kl-1):
    a=str(a)
    a=a+'7'
    a=int(a)
if K%2==0:
    print('-1')
else:
    while a%K!=0:
        a=str(a)
        a=a+'7'
        a=int(a)
    a=str(a)
    print(a)
    print(len(a))

Submission status: Wrong Answer

Solution code:
s = int(input()) 

L=[7,
77,
777,
7777,
77777,
777777,
7777777,
77777777,
777777777,
7777777777,
77777777777,
777777777777,
7777777777777,
77777777777777,
777777777777777,
7777777777777777,
77777777777777777]

ans=0
for i,a in enumerate(L):
    if a % s==0:
        break
    ans=i+2
else :
    ans=-1
print(ans)

Submission status: Wrong Answer

Solution code:
def main():
  k_str = input()
  k_int = int(k_str)
  if int(k_str[-1]) == 0 or 2 or 4 or 5 or 6 or 8:
    return print(-1)
  else:
    seven_sequence = 0
    which = 0
    for i in range(10**6 + 1):
      seven_sequence += 7*(10**i)
      if seven_sequence % k_int == 0:
        ans = i + 1
        which += 1
        break
    if which:
      return print(ans)
    else:
      return print(-1)

main()

Submission status: Wrong Answer

Solution code:
k=int(input())

x=0
c=7

if k%2==0:
    print('-1')
else:
    while True:
        if c%k==0:
            break
            print(x)
        else:
            c=str(c)
            c=int(c+'7')
            x+=1

Submission status: Wrong Answer

Solution code:
num = int(input())
count = 0
while count < 1000:
    count += 1
    int7 = int("7" * count)
    if int7 % num == 0:
        print(count)
        exit()
print(-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
flag = 0
if(K%2==0):
  print("-1")
elif(K==1 or K==7):
  print(1)
elif(K==77 or K==777 or K==7777 or K==77777 or K==777777):
  print(len(str(K)))
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:
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 == 10000:
            print(k-1)
            break
        else:
            cnt += 1
            n += '7'