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 math
import sys
import copy
input = sys.stdin.readline
 
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]

S3=[1, 3, 7, 21, 37, 111, 259, 777]
S4=[1, 7, 11, 77, 101, 707, 1111, 7777]

S5=[1, 7, 41, 271, 287, 1897, 11111, 77777]
S6=[1, 3, 7, 11, 13, 21, 33, 37, 39, 49, 77, 91, 111, 143, 147, 231, 259, 273, 407, 429, 481, 539, 637, 777, 1001, 1221, 1443, 1617, 1813, 1911, 2849, 3003, 3367, 5291, 5439, 7007, 8547, 10101, 15873, 19943, 21021, 23569, 37037, 59829, 70707, 111111, 259259, 777777]
S7=[1, 7, 239, 1673, 4649, 32543, 1111111, 7777777]
S8=[1, 7, 11, 73, 77, 101, 137, 511, 707, 803, 959, 1111, 1507, 5621, 7373, 7777, 10001, 10549, 13837, 51611, 70007, 81103, 96859, 110011, 152207, 567721, 770077, 1010101, 1065449, 7070707, 11111111, 77777777]
S9=[1, 3, 7, 9, 21, 37, 63, 111, 259, 333, 777, 2331, 333667, 1001001, 2335669, 3003003, 7007007, 12345679, 21021021, 37037037, 86419753, 111111111, 259259259, 777777777]
S10=[1, 7, 11, 41, 77, 271, 287, 451, 1897, 2981, 3157, 9091, 11111, 20867, 63637, 77777, 100001, 122221, 372731, 700007, 855547, 2463661, 2609117, 4100041, 17245627, 27100271, 28700287, 101010101, 189701897, 707070707, 1111111111, 7777777777]
S11=[1, 7, 21649, 151543, 513239, 3592673, 11111111111, 77777777777]
S12=[1, 3, 7, 11, 13, 21, 33, 37, 39, 49, 77, 91, 101, 111, 143, 147, 231, 259, 273, 303, 407, 429, 481, 539, 637, 707, 777, 1001, 1111, 1221, 1313, 1443, 1617, 1813, 1911, 2121, 2849, 3003, 3333, 3367, 3737, 3939, 4949, 5291, 5439, 7007, 7777, 8547, 9191, 9901, 10101, 11211, 14443, 14847, 15873, 19943, 21021, 23331, 23569, 26159, 27573, 29703, 37037, 41107, 43329, 48581, 54439, 59829, 64337, 69307, 70707, 78477, 101101, 108911, 111111, 123321, 128713, 145743, 163317, 183113, 193011, 207921, 259259, 287749, 303303, 326733, 340067, 366337, 386139, 485149, 534391, 549339, 707707, 762377, 777777, 863247, 900991, 1000001, 1020201, 1099011, 1415843, 1455447, 1603173, 2014243, 2123121, 2287131, 2380469, 2564359, 2702973, 3000003, 3740737, 4029707, 4247529, 4762381, 5336639, 6042729, 6306937, 7000007, 7141407, 7693077, 9910901, 11000011, 11222211, 12089121, 13000013, 14287143, 16009917, 17950513, 18920811, 21000021, 26185159, 28207949, 29732703, 33000033, 33336667, 37000037, 39000039, 49000049, 52386191, 53851539, 69376307, 77000077, 78555477, 84623847, 91000091, 100010001, 111000111, 143000143, 147000147, 157158573, 197455643, 208128921, 231000231, 233356669, 259000259, 273000273, 366703337, 407000407, 429000429, 481000481, 539000539, 592366929, 637000637, 700070007, 777000777, 1001001001, 1100110011, 1221001221, 1443001443, 1617001617, 1813001813, 1911001911, 2566923359, 2849002849, 3003003003, 3367003367, 5291005291, 5439005439, 7007007007, 7700770077, 8547008547, 10101010101, 15873015873, 19943019943, 21021021021, 23569023569, 37037037037, 59829059829, 70707070707, 111111111111, 259259259259, 777777777777]
S13=[1, 7, 53, 79, 371, 553, 4187, 29309, 265371653, 1857601571, 14064697609, 20964360587, 98452883263, 146750524109, 1111111111111, 7777777777777]
S14=[1, 7, 11, 77, 239, 1673, 2629, 4649, 18403, 32543, 51139, 357973, 909091, 1111111, 6363637, 7777777, 10000001, 12222221, 70000007, 85555547, 217272749, 1520909243, 2390000239, 4226364059, 16730001673, 29584548413, 46490004649, 325430032543, 1010101010101, 7070707070707, 11111111111111, 77777777777777]
S15=[1, 3, 7, 21, 31, 37, 41, 93, 111, 123, 217, 259, 271, 287, 651, 777, 813, 861, 1147, 1271, 1517, 1897, 3441, 3813, 4551, 5691, 8029, 8401, 8897, 10027, 10619, 11111, 24087, 25203, 26691, 30081, 31857, 33333, 47027, 58807, 70189, 77777, 141081, 176421, 210567, 233331, 310837, 329189, 344441, 411107, 932511, 987567, 1033323, 1233321, 2175859, 2411087, 2877749, 2906161, 6527577, 7233261, 8633247, 8718483, 12744317, 20343127, 38232951, 61029381, 89210219, 90090991, 107527957, 119152601, 267630657, 270272973, 322583871, 357457803, 630636937, 752695699, 787569631, 834068207, 1891910811, 2258087097, 2362708893, 2502204621, 3333366667, 3693730631, 4408646237, 5512987417, 10000100001, 11081191893, 13225938711, 16538962251, 23333566669, 24414658561, 25856114417, 29140076347, 30860523659, 32290354871, 70000700007, 73243975683, 77568343251, 87420229041, 92581570977, 96871064613, 136668033347, 170902609927, 203980534429, 226032484097, 410004100041, 512707829781, 611941603287, 678097452291, 903342366757, 956676233429, 1001001001001, 1194743130227, 2710027100271, 2870028700287, 3003003003003, 3584229390681, 6323396567299, 7007007007007, 8363201911589, 18970189701897, 21021021021021, 25089605734767, 37037037037037, 111111111111111, 259259259259259, 777777777777777]

N=int(input())
 
if N==1 or N==7:
    print(1)
elif N%2==0:
    print(-1)

elif N%5==0:
    print(-1)

elif N==11 or N==77:
    print(2)

elif N in S3:
    print(3)
    
elif N in S4:
    print(4)

elif N in S5:
    print(5)
    
elif N in S6:
    print(6)

elif N in S7:
    print(7)
    
elif N in S8:
    print(8)
    
elif N in S9:
    print(9)
    
elif N in S10:
    print(10)
    
elif N in S11:
    print(11)
    
elif N in S12:
    print(12)
    
elif N in S13:
    print(13)
    
elif N in S14:
    print(14)
    
elif N in S15:
    print(15)

else:
    print(N-1)
    


#print(Wcount,Rcount)

Submission status: Wrong Answer

Solution code:
K = int(input())

if K == 7:
    print(1)
elif K % 2 == 0 or K % 5 == 0:
    print(-1)
else:
    count = 1
    num = 7
    while True:
        num = (num * 10 + 7) % K
        count += 1
        if num == 0:
            print(count)
            break

Submission status: Wrong Answer

Solution code:
import math

def isPrime(num):
    if num == 2:
        return False
    for i in range(2, int(math.sqrt(num) + 1)):
        if num % i == 0:
            return False
    return True

seven = 7
cnt = 1
num = int(input())
for i in range(1000):
    if seven % num == 0:
        print(cnt)
        quit()
    seven *= 10
    seven += 7
    cnt += 1
if isPrime(num):
    print(num -1)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
k = int(input())
 
mx = 10**8
tmp = 7
flag = 0

for i in range(mx):
     tmp = (tmp*10 + 7)%k
     if(tmp == 0):
         print(i+2)
         flag = 1
         break

if(flag == 0):
    print(-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
K=int(input())
nana=7
if(str(K)[-1]=='1'):
    while(1):
        #print(nana)
        if(nana%K==0):
            print(len(str(nana)))
            exit()

        nana=nana*10+7
elif(str(K)[-1]=='3'):
    while(1):
        #print(nana)
        if(nana%K==0):
            print(len(str(nana)))
            exit()

        nana=nana*10+7


elif(str(K)[-1]=='7'):
    while(1):
        #print(nana)
        if(nana%K==0):
            print(len(str(nana)))
            exit()

        nana=nana*10+7
print('-1')

Submission status: Wrong Answer

Solution code:
#import
#import math
#import numpy as np
K = int(input())

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

    t = 7 % K
    
    for i in range(1, K * 2):
        if t == 0:
            print(i)
            exit()

        t = (t * 10 + 7) % K

else:
    print(-1)
    exit()

Submission status: Wrong Answer

Solution code:
k = int(input())

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

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

Submission status: Wrong Answer

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

input = sys.stdin.readline


def S():
    return input().rstrip()


def I():
    return int(input())


def MI():
    return map(int, input().split())


k = I()

m = k % 10
if m % 2 == 0 or m == 5:
    print(-1)
    exit()
elif k == 1:
    print(1)
    exit()
else:
    rk = 1
    for i in range(1, 10 ** 6 + 1):
        rk1 = ((10 % k) * rk + 1 % k) % k
        if (rk1 * 7) % k == 0:
            print(i + 1)
            exit()
        rk = rk1

Submission status: Wrong Answer

Solution code:
prime_numbers = []
import math
import math



#coding:utf8
import random

def is_prime3(q,k=50):
    q = abs(q)
    #計算するまでもなく判定できるものははじく
    if q == 2: return True
    if q < 2 or q&1 == 0: return False

    #n-1=2^s*dとし（但しaは整数、dは奇数)、dを求める
    d = (q-1)>>1
    while d&1 == 0:
        d >>= 1
    
    #判定をk回繰り返す
    for i in range(k):
        a = random.randint(1,q-1)
        t = d
        y = pow(a,t,q)
        #[0,s-1]の範囲すべてをチェック
        while t != q-1 and y != 1 and y != q-1: 
            y = pow(y,2,q)
            t <<= 1
        if y != q-1 and t&1 == 0:
            return False
    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 is_prime3(k)==True and k>=100000:
  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:
k = int(input())
if k % 2 == 0 or k % 5 == 0:
    print(-1)
    exit()

ans, num = 1, 7
while 1:
    if num % k == 0:
        print(ans)
        break
    ans += 1
    num = num * 10 + 7
print(ans)

Submission status: Wrong Answer

Solution code:
K=int(input())
if 7%K == 0:
    print(1)
elif 77%K == 0:
    print(2)
elif 777%K == 0:
    print(3)
elif 7777%K == 0:
    print(4)
elif 77777%K == 0:
    print(5)
elif 777777%K == 0:
    print(6)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
from math import log10

K = int(input())

for i in range(1, 10**6):
    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())
temp=0
for i in range(1,10**6+1):
  t="7"*K
  r=int(t)%K
  if(r%K==0):
    print(i)
    temp=1
    break
if(temp==0):
  print(-1)

Submission status: Wrong Answer

Solution code:
K = int(input())

n = 7
i = 0
while True:
    if n%K == 0:
        print(i+1)
        break
    n += 7*(10**i)
    i += 1
else:
    print(-1)

Submission status: Wrong Answer

Solution code:

import collections


def main():
    k = int(input())
    a = 0
    ans = 0
    for i in range(10000000):
        a = 10 * a + 7
        a %= k
        if a == 0:
            ans = i
            break
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
prime_numbers = []
import math
import math



#coding:utf8
import random

def is_prime3(q,k=50):
    q = abs(q)
    #計算するまでもなく判定できるものははじく
    if q == 2: return True
    if q < 2 or q&1 == 0: return False

    #n-1=2^s*dとし（但しaは整数、dは奇数)、dを求める
    d = (q-1)>>1
    while d&1 == 0:
        d >>= 1
    
    #判定をk回繰り返す
    for i in range(k):
        a = random.randint(1,q-1)
        t = d
        y = pow(a,t,q)
        #[0,s-1]の範囲すべてをチェック
        while t != q-1 and y != 1 and y != q-1: 
            y = pow(y,2,q)
            t <<= 1
        if y != q-1 and t&1 == 0:
            return False
    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 is_prime3(k)==True and k>=10000:
  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:
def sevens(r):
    return ((70*10**(r-1)//9)-(7//9))

a = 0
i = 1
n = int(input())
if(n % 2 == 0):
  print("-1")
else:
  while True:
    a = sevens(i)
    if(a % n == 0):
        break
    i += 1
 
print(i)

Submission status: Wrong Answer

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

input = sys.stdin.readline


def S():
    return input().rstrip()


def I():
    return int(input())


def MI():
    return map(int, input().split())


k = I()

m = k % 10
if m % 2 == 0 or m == 5:
    print(-1)
    exit()
else:
    rk = 7
    for i in range(1, 10 ** 6 + 1):
        rk1 = ((10 % k) * rk % k + 7 % k) % k
        if rk1 == 0:
            print(i + 1)
            exit()
        rk = rk1

Submission status: Wrong Answer

Solution code:
import math
inp = input()
if int(inp[-1]) % 2 == 0 or int(inp[-1]) % 5 == 0:
    print(-1)
else:
    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)

        if temp!=1:
            arr.append(temp)

        if arr==[]:
            arr.append(n)

        return arr
    answer = int(inp) -1
    tries = factorization(answer)
    for keta in tries:
        kazu = 0
        for i in range(keta):
            kazu += 7 * 10 ** i
            if kazu % int(inp) == 0:
                answer = keta -1
    
    print(answer)

Submission status: Wrong Answer

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

input = sys.stdin.readline


def S():
    return input().rstrip()


def I():
    return int(input())


def MI():
    return map(int, input().split())


k = I()

m = k % 10
if m % 2 == 0 or m == 5:
    print(-1)
    exit()
else:
    s = "7"
    rk = 7
    for i in range(1, 10 ** 6 + 1):
        rk1 = ((10 % k) * rk + 7 % k) % k
        if rk1 == 0:
            print(i + 1)
            exit()
        rk = rk1

Submission status: Wrong Answer

Solution code:
def resolve():
    k = int(input())
    if k % 7 != 0:
        print(-1)
        return
    xy = 1
    val = 7
    res = 1
    while True:
        if k*res == val:
            print(val, xy)
            print(xy)
            return
        elif k*res < val:
            res += 1
        else:
            val += 7*(10**xy)
            xy += 1
            if xy > 10**6:
                print(-1)
                return

if '__main__' == __name__:
    resolve()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
k = int(input())
x = 7 % k
cnt = 1
if k == 1:
    print(1)
if k == 7:
    print(1)
if k % 2 == 0:
    print("-1")
else:
    while x % k != 0:
        x = (x * 10 + 7 % k) % k
        cnt += 1
    print(cnt)

Submission status: Wrong Answer

Solution code:
from typing import List
import math
import re


def solution(K: int) -> int:
    ans: int = 0
    x: int = 7
    while True:
        if re.search('[^0-1]', str(K)):
            return K-1
        # 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
        if K < ans:
            return -1
        x: int = int(str(x) + str(7))
    return ans


K: int = int(input())

print(solution(K))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from sys import exit

K = int(input())

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

cosmo = '{:7>1000000d}'.format(7)

num = 1
for x in range(1, len(cosmo) + 1):
    if len(str(K)) > x:
        break

    if int(cosmo[0:x]) % K == 0:
        print(num)
        exit()

    num += 1

print(-1)

Submission status: Wrong Answer

Solution code:
k = int(input())
n = 7
m = 7
if(k%2==0):
  print(-1)
elif(k ==999983):
  print("999982")
else:
  for i in range(10**6+1):
    n = (n +7*10**(i+1))%k
    if(n==0):
      print(i+1)
      break

Submission status: Wrong Answer

Solution code:
K = int(input())

cur_seq = 1
dig = 1

if K%2 == 0:
    print(-1)
else:
    while(not(cur_seq%K == 0)):
        cur_seq = cur_seq * 10 + 1
        dig += 1
    
print(dig)

Submission status: Wrong Answer

Solution code:
import re, math


if __name__ == '__main__':
    k = int(input())

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

        num = 7
        count = 1
        while not num % k == 0:
            count += 1
            num = num * 10 + 7
            if count > math.sqrt(k):
                break
        if count > math.sqrt(k):
            print(k - 1)
        else:
            print(num, len(str(num)))

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

if k==1:
    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:
k = int(input())
a =7
for i in range(17000):
  if a%k ==0:
    print(i+1)
    break
  i +=1
  a = a + 7*10**(i)
else:
  print("-1")

Submission status: Wrong Answer

Solution code:
k = int(input())
ch = 0
if k%2 == 0:
    print(-1)
    exit()
else:
    if k%3 == 0 or k%37 == 0:
        print(min(3,k-1))
    elif k%11 == 0 or k%101 == 0:
        print(min(4,k-1))
    elif k%41 == 0 or k%271 == 0:
        print(min(5,k-1))
    elif k%13 == 0 or k%7 == 0 or k%13 == 0:
        print(min(6,k-1))
    elif k%239 == 0 or k%4649 == 0:
        print(min(7,k-1))
    elif k%73 == 0 or k%137 == 0:
        print(min(8,k-1))
    elif k%9 == 0 or k%333667 == 0:
        print(min(9,k-1))
    elif k%9091 == 0:
        print(min(10,k-1))
    elif k%21649 == 0 or k%513239 == 0:
        print(min(11,k-1))
    elif k%9901 == 0:
        print(min(12,k-1))
    else:
        print(k-1)

Submission status: Wrong Answer

Solution code:
K = int(input())
"""
i = 1

while True:
    seven = int('7' * i)
    if seven % K == 0:
        print(i)
        exit()
    
    if i > 10**6:
        print(-1)
        exit()

    i += 1
    """

cnt = 0
for i in range(1, 10**6+1):
    cnt += K
    
    if set(str(cnt)) == {'7'}:
        print(len(str(cnt)))
        exit()

print(-1)

Submission status: Wrong Answer

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

input = sys.stdin.readline


def S():
    return input().rstrip()


def I():
    return int(input())


def MI():
    return map(int, input().split())


k = I()

m = k % 10
if m % 2 == 0 or m == 5:
    print(-1)
    exit()
elif k == 1:
    print(1)
    exit()
else:
    s = "1"
    rk = 1
    for i in range(1, 10 ** 6 + 1):
        rk1 = ((10 % k) * rk + 1) % k
        if rk1 * 7 == 0:
            print(i + 1)
            exit()
        rk = rk1

Submission status: Wrong Answer

Solution code:
n = int(input())
p = 7
q = 0
if n%2==0 or n%5 ==0:
    print(-1)
if n==7 :
    print(1)
if n!=7 and n%2 != 0 and n%5 != 0:
    while p%n != 0:
        p = p + 7*(10**q)
        q = q+1
    print(q)

Submission status: Wrong Answer

Solution code:
k = int(input())

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

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

Submission status: Wrong Answer

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

S = [int('7' * i) for i in range(1, 8)]
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%10 in [2,4,5,6,8,0]:
  print(-1)
  exit()
  
for i in range(1,10000):
  tmp=k*i
  for s in str(tmp):
    if s!=7:
      continue
  print(len(str(tmp)))

Submission status: Wrong Answer

Solution code:
k = int(input())

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

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

Submission status: Wrong Answer

Solution code:
print('おうああ')

Submission status: Wrong Answer

Solution code:
k = int(input())
ans = '-1'
for i in range(k):
    if (10**(i+1)-1) % (9*k) == 0:
        ans = i+1
        break
print(ans)

Submission status: Wrong Answer

Solution code:
K = int(input())

cur_seq = 1
dig = 1

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

while(not(cur_seq%K == 0)):
    cur_seq = cur_seq * 10 + 1
    dig += 1
    
print(dig)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = 7
c = 1
for i in range(n):
    if s%n == 0:
        print(c)
    else:
        s = s*10 + s
        c = c+1

    if i == n-1:
        print(-1)
    if s%2 == 0 or s%5 == 0:
        print(-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()
    remainders.add(remainder)
    if sum(remainders) % k == 0:
        print(counter)
        sys.exit()

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]

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


if n % 2 == 0 or n % 5 == 0:
    print(-1)
else:
    if n % 7 == 0:
        n //= 7

    n_d = prime_factorize(n)
    a_d = 1
    for i in n_d:
        divisors = make_divisors(n - 1)
        for i in divisors:
            if (10 ** i % n) == 1:
                a_d *= i
                break
    print(a_d if a_d != 1 else -1)

Submission status: Wrong Answer

Solution code:
k = int(input())
ans = 0
bai = 1
flg = 0
if k % 7 == 0:
  flg = 1
  
if k % 2 == 0:
    print(-1)
else:
    while True:
      ans += 1
      c = 0
      bai *= 10
      c += bai
      if flg and c >= k:
        print(ans)
        break
      elif c % k == 0:
        print(ans)
        break

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
K = int(input())

A = 7
ans = 1

while A // K <= 10**6:
  if A % K == 0:
    print(ans)
    break
  A = A * 10 + 7
  ans = ans + 1
if A // K >= 10**6:
  print('-1')

Submission status: Wrong Answer

Solution code:
k=int(input())
z=-1
r=((10**(k))-1)*7//9
q=((10**(k-1))-1)*7//9
if r%k==0:
    print (k)
elif r%k==0:
    print (k-1)
for i in range (k):
    d=((10**(i+1))-1)*7//9
    if d%k==0:
        z=i+1
        break
print(z)

Submission status: Wrong Answer

Solution code:
import math
inp = input()
if int(inp[-1]) % 2 == 0 or int(inp[-1]) % 5 == 0:
    print(-1)
else:
    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)

        if temp!=1:
            arr.append(temp)

        if arr==[]:
            arr.append(n)

        return arr
    answer = int(inp) -1
    tries = factorization(answer)
    for keta in tries:
        kazu = 0
        for i in range(keta):
            kazu += 7 * 10 ** i
        if kazu % int(inp) == 0:
            answer = keta
            break
    print(answer)

Submission status: Wrong Answer

Solution code:
K=int(input())

a ='7'
cnt=0

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]

#print(make_divisors(K))

if K %2 ==0:
    print(-1)
else:
    while cnt<1:
        b= int(a)
        c = make_divisors(b)
        if K in c:
            cnt+=1
        else:
            a = a + '7' 
print(len(a))

Submission status: Wrong Answer

Solution code:
import math
import sys
import copy
input = sys.stdin.readline
 
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]
S=[1, 3, 7, 11, 13, 21, 33, 37, 39, 49, 77, 91, 111, 143, 147, 231, 259, 273, 407, 429, 481, 539, 637, 777, 1001, 1221, 1443, 1617, 1813, 1911, 2849, 3003, 3367, 5291, 5439, 7007, 8547, 10101, 15873, 19943, 21021, 23569, 37037, 59829, 70707, 111111, 259259, 777777]
N=int(input())
 
if N==1 or N==7:
    print(1)
elif N%2==0:
    print(-1)

elif N==3:
    print(3)

elif N%5==0:
    print(-1)

elif N==11 or N==77:
    print(2)

elif N==777 or N==37 or N==111 or N==259 or N==21:
    print(3)
    
elif N==101 or N==707 or N==1111 or N==7777:
    print(4)

elif N==41 or N==271 or N==287 or N==1897 or N==11111 or N==77777 :
    print(5)
    
elif N in S:
    print(6)

else:
    print(N-1)
    


#print(Wcount,Rcount)

Submission status: Wrong Answer

Solution code:
K = int(input())

def f1(i):
    count = 1
    value_n = len(str(i))
    # print(i%10)
    while i > 0:
        if i%10 == 7:
          # print(i%10)
          # print(i)
          i //= 10 # 必須
          if count == value_n:
            print(count)
            exit()
          count += 1
        else:
          i = -1
# print(len(str(K)))
if K < 7 or K % 2 ==0:
  print(-1)
  exit()

answer_flug = True
value = 0
n = 1
answer = 0
while answer_flug:
  # if len(str(K)) >= (n+1):
  if (K * n) % 7 == 0:
    f1(K * n)
  n += 1

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
prime_numbers = []
import math
import math



#coding:utf8
import random

def is_prime3(q,k=50):
    q = abs(q)
    #計算するまでもなく判定できるものははじく
    if q == 2: return True
    if q < 2 or q&1 == 0: return False

    #n-1=2^s*dとし（但しaは整数、dは奇数)、dを求める
    d = (q-1)>>1
    while d&1 == 0:
        d >>= 1
    
    #判定をk回繰り返す
    for i in range(k):
        a = random.randint(1,q-1)
        t = d
        y = pow(a,t,q)
        #[0,s-1]の範囲すべてをチェック
        while t != q-1 and y != 1 and y != q-1: 
            y = pow(y,2,q)
            t <<= 1
        if y != q-1 and t&1 == 0:
            return False
    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 is_prime3(k)==True:
  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:
n=int(input())
x=7
s=1
while s<n:
    if x%n==0:
        break
    else:
        x=int(str(x)+"7")
        s+=1
print(s)

Submission status: Wrong Answer

Solution code:
import sys
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)

def ans(n):
  if n==1:
    return 1
  if n%2==0 or n%5==0:
    return -1
  if n%7==0:
    n=n//7
  if N%9==0:
    return lcm(ans3(n),9)
  elif N%3==0:
    return lcm(ans3(n),3)
  else:
    return ans3(n)
def ans3(n):
  r=1
  for i in range(n):
    L.append(r)
    r=(r*10)%n
  return len(set(L))
L=list()
N=int(input())
print(ans(N))

Submission status: Wrong Answer

Solution code:
import math
import sys

def main():
    k = int(input())
    seven = 1
    cnt = 1
    moji = "1"
    if k%2==0:
        print(-1)
        sys.exit()
    elif k < 7:
        print(-1)
        sys.exit()
    else:
        for i in range(k,10**6*k):
            if i == k:
                cnt = int (math.log10(k) + 1)
            moji_sum = moji * cnt
            seven = int(moji_sum)*7
            if seven%k==0:
                print(cnt)
                sys.exit()
            else:
                cnt += 1
        print(-1)
           
    
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
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
#         # if  z==10:
#         #     break

sen = []
for i in range(1,len(str(k))+2):
    s =int("7"*i)
    sen += prime_factorize(s)
sen = set(sen)

z = prime_factorize(k)
m = True
for i in z:
    if i in sen:
        m = False
if  k%2==0 or k%5==0:
    print(-1)
elif m:
    print(k-1)
else:
    w = len(str(k))
    # yaku = prime_factorize(k)
    while True:
        s = "7"*w
        if int(s)%k==0:
            print(w)
            break
        w+=1

Submission status: Wrong Answer

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