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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
k = int(input())

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

n_map = {}
current = 7
cnt = 1
while True:
    if current == 0:
        print(cnt)
        exit()
    if current in n_map:
        print(-1)
        exit()
    else:
        n_map[current] = True
    cnt += 1

    current = 10 % k * current + 7
    current %= k

Submission status: Wrong Answer

Solution code:
K = int(input())
m = 1

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

while True:
    a = int("7" * m) % K
    if a == 0:
        print(int("7" * m) // K)
        break
    else:
        m += 1

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C_fix
# CreatedDate:  2020-08-05 23:00:31 +0900
# LastModified: 2020-08-05 23:11:40 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd


def main():
    k = int(input())
    amari = []
    seven = 0
    i = 0
    while 1:
        seven = (seven + 7*(10**i)) % k
        if seven == 0:
            print(i+1)
            return
        elif seven in amari:
            print(-1)
            return
        i += 1
        amari.append(seven)
        print(seven)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C
# CreatedDate:  2020-08-03 01:50:32 +0900
# LastModified: 2020-08-04 00:06:23 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd
#dic = {7: [7], 77: [7, 11], 777: [3, 7, 37], 7777: [7, 11, 101], 77777: [7, 41, 271], 777777: [3, 7, 7, 11, 13, 37], 7777777: [7, 239, 4649], 77777777: [7, 11, 73, 101, 137], 777777777: [3, 3, 7, 37, 333667], 7777777777: [7, 11, 41, 271, 9091]}

def main():
    k = int(input())
    ans_dict = {7: [7], 77: [7, 11], 777: [3, 7, 37], 7777: [7, 11, 101], 77777: [7, 41, 271], 777777: [3, 7, 7, 11, 13, 37], 7777777: [7, 239, 4649], 77777777: [7, 11, 73, 101, 137], 777777777: [3, 3, 7, 37, 333667], 7777777777: [7, 11, 41, 271, 9091]}
    flag = 0
    for i, (key, value) in enumerate(ans_dict.items()):
        if k in value:
            flag = 1
            ans = i+1
            break
    if flag == 1:
        print(ans)
    else:
        print(-1)




if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
k = int(input())

if k==1 :
    ans=1
elif k % 2 ==0 or k%5==0:
    ans=-1
else:
    l=9*k
    v=1
    for i in range(1, l+1):
        v=(v*10) % l
        if v == 1:
            ans=i
            break
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    k = int(input())
    if k % 2 == 0 or k % 5 == 0:
        print(-1)
        sys.exit()
    if k % 7 == 0:
        l = k * 9 // 7
    else:
        l = k * 9
    r = 1       # カウント
    p = 10 ** r
    while (p % l) != 1:
        p = (p * 10) % k
        r += 1
    print(r)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
K = int(input())
count = 1
number = 7
while count < 1000000:
    if number%K==0:
        print(count) 
        break
    else:
        number = number*10 + 7
        count += 1
print(-1)

Submission status: Wrong Answer

Solution code:
K = int(input())
if K==7 or K==1:
        print(1)
if K==11:
        print(2)
if K in (3,37,3*37):
    print(3)
if K in (11,101,1111):
    print(4)
if K in (41,271,11111):
    print(5)
if K in (3, 7, 11, 13, 21, 33, 37, 39, 77, 91, 111, 143, 231, 259, 273, 407, 429, 481, 777, 1001, 1221, 1443, 2849, 3003, 3367, 5291, 8547, 10101, 15873, 37037, 111111):
    print(6)
if K in (239,4649,239*4649):
    print(7)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
K = int(input())
if K==7 or K==1:
        print(1)
if K==11:
        print(2)
if K in (3,37,3*37):
    print(3)
elif K in (11,101,1111):
    print(4)
elif K in (41,271,11111):
    print(5)
elif K in (1, 3, 7, 11, 13, 21, 33, 37, 39, 77, 91, 111, 143, 231, 259, 273, 407, 429, 481, 777, 1001, 1221, 1443, 2849, 3003, 3367, 5291, 8547, 10101, 15873, 37037, 111111):
    print(6)
elif K in (239,4649,239*4649):
    print(7)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
K = int(input())
if K==7 or K==1:
        print(1)
if K==11:
        print(2)
if K in (3,37,3*37):
    print(3)
elif K in (11,101,1111):
    print(4)
elif K in (41,271,11111):
    print(5)
elif K in (1, 3, 7, 11, 13, 21, 33, 37, 39, 77, 91, 111, 143, 231, 259, 273, 407, 429, 481, 777, 1001, 1221, 1443, 2849, 3003, 3367, 5291, 8547, 10101, 15873, 37037, 111111):
    print(6)
elif K in (41,271,41*271):
    print(7)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
k = int(input())

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

ans = 1
r = 0
x = 0
while(True):
    if x == (r * 10 + 7) // k and r == (r * 10 + 7) % k:
        print(-1)
        exit()

    x = (r * 10 + 7) // k
    r = (r * 10 + 7) % k

    if r == 0:
        break
    else:
        ans += 1
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
K = int(input())
mod = K
if K == 1:
    print(1)
elif K % 2 == 0 or K % 5 == 0:
    print(-1)
elif K % 7 != 0:
    x = 10 % mod
    y = 1 % mod
    X = [y] * K
    S = [y] * K
    for i in range(1, K + 1):
        X[i] = (X[i - 1] * x) % mod
        S[i] = S[i - 1] + X[i]
        if S[i] % mod == 0:
            print(i + 1)
            exit()
        elif X[i] == 1 % mod:
            loop = i
            print(loop * mod - 1)
            exit()
else:
    mod = K // 7
    if mod == 1:
        print(1)
    else:
        x = 10 % mod
        y = 1 % mod
        X = [y] * K
        S = [y] * K
        for i in range(1, K + 1):
            X[i] = (X[i - 1] * x) % mod
            S[i] = S[i - 1] + X[i]
            if S[i] % mod == 0:
                print(i + 1)
                exit()
            elif X[i] == 1 % mod:
                loop = i
                print(loop * mod - 1)
                exit()

Submission status: Wrong Answer

Solution code:
K = int(input())
mod = K
if K == 1:
    print(1)
elif K % 2 == 0 or K % 5 == 0:
    print(-1)
elif K % 7 != 0:
    x = 10 % mod
    y = 1 % mod
    X = [y] * K
    S = [y] * K
    for i in range(1, K + 1):
        X[i] = (X[i - 1] * x) % mod
        S[i] = S[i - 1] + X[i]
        if S[i] % mod == 0:
            print(i + 1)
            exit()
        elif X[i] == 1 % mod:
            loop = i
            print(loop * K)
            exit()
else:
    mod = K // 7
    if mod == 1:
        print(1)
    else:
        x = 10 % mod
        y = 1 % mod
        X = [y] * K
        S = [y] * K
        for i in range(1, K + 1):
            X[i] = (X[i - 1] * x) % mod
            S[i] = S[i - 1] + X[i]
            if S[i] % mod == 0:
                print(i + 1)
                exit()
            elif X[i] == 1 % mod:
                loop = i
                print(loop * K)
                exit()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
K = int(input())

if K%2 == 0:
    print(-1)
else:
    ans = 0
    tmp = 0
    for i in range(K):
        print(i)
        tmp = tmp*10+7
        if tmp%K == 0:
            print(i+1)
            exit()
        else:
            continue
    print(-1)

Submission status: Wrong Answer

Solution code:
import math
# your code goes here
x = int(input())
i = 1
n= 0
if x % 2 == 0 or x % 5 == 0:
    print(-1)
elif  math.gcd(10,x)!=1:
    print(-1)
else:
    for i in range(1, 1000000):
 
        l =( 7 %x*pow(9,-1)%x* (pow(10,i,x) - 1%x)%x )%x
        #l=math.ceil(l)
        
        n+=1
        
        if l % x == 0:
            break
    print(n)

Submission status: Wrong Answer

Solution code:
# your code goes here
x = int(input())
i = 1
n= 0
if x % 2 == 0 or x % 5 == 0:
    print(-1)
else:
    for i in range(1, 1000000):

        l =( 7 %x*pow(9,-1)%x* (pow(10,i,x) - 1%x)%x )%x
        #l=math.ceil(l)
        
        n+=1
        
        if l % x == 0:
            break
    print(n)

Submission status: Wrong Answer

Solution code:
k = int(input())

result = -1
m = 7
for i in range(1,k):
    check = m % k
    if check == 0:
        result = i
        break
    m = (10*m + 7) % k
    
print(result)

Submission status: Wrong Answer

Solution code:
k = int(input())

if str(k)[-1] not in ["1","3","7","9"]:
    print(-1)
    exit()

tmp = 7
i = 1
while True:
    if tmp == 0:
        print(i)
        exit()
    tmp = (tmp*10 + 7)%k
    i += 1

Submission status: Wrong Answer

Solution code:
mod = int(input())

if (mod<7):
    print("-1")
    
val = 7 % mod
i = 1

while(i < 1e7):
    if(val == 0):
        print(i)
        break   

    val = (val * 10 + 7) % mod
    i += 1
print("-1")

Submission status: Wrong Answer

Solution code:
mod = int(input())

if (mod<7):
    print("-1")
    
val = 7 % mod
i = 1

while(i < 1e7):
    if(val == 0):
        print(i)
        break   

    val = (val * 10 + 7) % mod
    i += 1

Submission status: Wrong Answer

Solution code:
K = int(input())

flag = [0 for _ in range(K)]  # flag[i] : あまり i が登場したかどうか

if 7%K == 0:
    print(0)
else:
    now_n = 7%K
    flag[now_n] = 1
    while True:
        next_n = (now_n*10 + 7) % K
        if next_n == 0:
            print(sum(flag)+1)
            exit()
        elif flag[next_n] == 0:
            now_n = next_n
            flag[now_n] = 1
        else:
            print(-1)
            exit()

Submission status: Wrong Answer

Solution code:
K = int(input())

flag = [0 for _ in range(K)]  # flag[i] : あまり i が登場したかどうか

if 7%K == 0:
    print(0)
else:
    now_n = 7%K
    while True:
        flag[now_n] = 1
        next_n = (now_n*10 + 7) % K
        if next_n == 0:
            print(sum(flag)+1)
            exit()
        elif flag[next_n] == 0:
            now_n = next_n
        else:
            print(-1)
            exit()

Submission status: Wrong Answer

Solution code:
K = int(input())

flag = [0 for _ in range(K)]  # flag[i] : あまり i が登場したかどうか

if 7%K == 0:
    print(0)
else:
    now_n = 7%K
    while True:
        flag[now_n] = 1
        next_n = (now_n*10 + 7) % K
        if next_n == 0:
            print(sum(flag))
            exit()
        elif flag[next_n] == 0:
            now_n = next_n
        else:
            print(-1)
            exit()

Submission status: Wrong Answer

Solution code:
# ABC174A

def func(k):
    if k % 2 == 0 or k % 5 == 0:
        return -1
    else:
        s = 0
        for i in range(1, 1000000):
            s = 10 * s + 7
            if s % k == 0:
                return i
                break
        else:
            return -1

k = int(input())
func(k)

Submission status: Wrong Answer

Solution code:
K = int(input())

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

Submission status: Wrong Answer

Solution code:
k = int(input())
c = 0
if k%2 ==0 or k%5==0:
    print(-1)
    c=1
if c==0:

    for i in range(1,k):
        t = "7"*i
        if int(t)%k==0 :
            print(i)
            break

Submission status: Wrong Answer

Solution code:
def main():
    K = int(input())
    l = [False] * K
    ans = 1
    now = 0
    while True:
        now = now * 10 + 7
        now %= 7
        if now == 0:
            print(ans)
            break

        if l[now]:
            print(-1)
            break
        
        l[now] = True
        ans += 1

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
1

Submission status: Wrong Answer

Solution code:
K = int(input())
x = 7
ans = 1
if x%K==0:
  print(ans)
visited = [0]*(K+1)
while x!=0:
  x %= K
  x = x*10+7
  x %= K
  if visited[x]:
    print(-1)
    exit()
  visited[x] = 1
  ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from math import sqrt
from collections import defaultdict
def main():
    k = int(input())
    if k % 2 == 0 or k % 5 == 0:
        print(-1)
        sys.exit()
    p = 7
    plus = 7
    amari = set()
    r = 1
    while p != 0:
        p = p % k
        if p in amari:
            print(r, -1, p)
            sys.exit()
        else:
            amari.add(p)
            plus = (plus * 10) % k
            p += plus
            r += 1

    print(r)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
K = int(input())
m = 7%K
ans = 1
s = set()
s.add(m)
for _ in range(K):
    if m == 0:
        print(ans)
        break
    m = (m*10+7)%K
    if m in s:
        print('-1')
        break
    ans += 1

Submission status: Wrong Answer

Solution code:
def main(k):
    size, res = 1, 7 % k
    while res and size <= k:
        res = (res * 10 + 7) % k
        size += 1
    return -1 if size > 1_000_000 else size


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

Submission status: Wrong Answer

Solution code:
#C

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

print(ans)

Submission status: Wrong Answer

Solution code:
K = int(input())
S = "7"
# i = int(S) // K
a = 0
c = 0
if K % 2 == 0:
    print(-1)
    exit()
a = 7 % K
for i in range(K + 1):
    if a == 0:
        print(i + 1)
        break
    a = (a * 10 + 7) % K

        

# while int(S) % K != 0:
    # if K % 2 == 0:
    #     i = -1
    #     break
    # S += "7"
    # i += 1
# print(i)

Submission status: Wrong Answer

Solution code:
K = int(input())
S = "7"
# i = int(S) // K
a = 0
c = 1
if K % 2 == 0:
    print(-1)
    exit()
a = 7 % K
for i in range(K + 1):
    if a == 0:
        break
    a = (a * 10 + 7) % K
    c += 1

print(c)

        

# while int(S) % K != 0:
    # if K % 2 == 0:
    #     i = -1
    #     break
    # S += "7"
    # i += 1
# print(i)

Submission status: Wrong Answer

Solution code:
K = int(input())
S = "7"
# i = int(S) // K
a = 0
c = 1
if K % 2 == 0:
    print(-1)
    exit()
a = 7 % K
for i in range(K):
    if a == 0:
        break
    a = (a * 10 + 7) % K
    c += 1

print(c)

        

# while int(S) % K != 0:
    # if K % 2 == 0:
    #     i = -1
    #     break
    # S += "7"
    # i += 1
# print(i)

Submission status: Wrong Answer

Solution code:
K = int(input())
S = "7"
# i = int(S) // K
a = 0
c = 1
if K % 2 == 0:
    print(-1)
    exit()
a = 7 % K
for i in range(K):
    a = (a * 10 + 7) % K
    if a == 0:
        c += 1
        break
    c += 1

print(c)

        

# while int(S) % K != 0:
    # if K % 2 == 0:
    #     i = -1
    #     break
    # S += "7"
    # i += 1
# print(i)

Submission status: Wrong Answer

Solution code:
k=int(input())

# mod k で考える
mod=k
flag=True
for i in range(1,10**6+1):
    if i<=7:
        if mod > 7 * int(str(1) * i):
            continue
    else:
        if mod==k:
            mod = 7 * int(str(1) * i) % mod
            if mod == 0:
                print(i)
                exit()
        else:
            mod= (mod*10+7)%k
            if mod==0:
                print(i)
                exit()

print(-1)

Submission status: Wrong Answer

Solution code:
import numpy as np

K = int(input())
end = int(str(K)[-1])
out_list = [2,4,5,6,8]
num=0

if(end in out_list):
  print(-1)
else:
  for i in range(10000):
    num += 7*10**i
    if(num%K==0):
      print(i+1)
      break

Submission status: Wrong Answer

Solution code:
k=int(input())

cur=7

for i in range(k+2):
    cur=(cur*10+7)%k
    if cur==0:
        print(i+2)
        exit()

print(-1)

Submission status: Wrong Answer

Solution code:
k=int(input())

# mod k で考える
mod=k

for i in range(1,k+2):
    if mod>7*int(str(1)*i):
        continue
    else:
        mod = 7 * int(str(1) * i) % mod
        if mod == 0:
            print(i)
            exit()

print(-1)

Submission status: Wrong Answer

Solution code:
k=int(input())
i=k
if(k%2==0 or k%5==0):
    print(-1)
while(1):
    if(7*(10**i-1)%(9*k)==0):
        break
    i-=1
print(i)

Submission status: Wrong Answer

Solution code:
K = int(input())
b = int(1000000 / K)
for i in range(b + 1):
    a = K * i
    if   a == 7:
        print('1')
        break
    elif a == 77:
        print('2')
        break
    elif a == 777:
        print('3')
        break
    elif a == 7777:
        print('4')
        break
    elif a == 77777:
        print('5')
        break
    elif a == 777777:
        print('6')
        break
    elif i == b :
        print('-1')
        break

Submission status: Wrong Answer

Solution code:
K = int(input())
seven = ''
ans = 0
for i in range(K):
    seven = seven + '7'
    if(int(seven) % K == 0):
        ans = i + 1
        break
    if(i == K - 1):
        print(-1)

print(ans)

Submission status: Wrong Answer

Solution code:
K=int(input())
count=0
result = -1
for i in range(K):
    count =(10*count+7)%K#余りからいく
    if count==0:
        result = i+1
print(result)

Submission status: Wrong Answer

Solution code:
K=int(input())
count=0
result = -1
for i in range(K):
    count =(10*count+7)%K#余りからいく
    if count%K==0:
        result = i+1
print(result)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
K=int(input())

count=0
result = -1
for i in range(K):
    count =(10*count+7)%K
    if count==0:
        result = i+1

print(result)

Submission status: Wrong Answer

Solution code:
n = int(input())
x, found = 0, False
for i in range(1, n):
  x = ((10 * x) + 7)%n
  if x == 0:
    print(i)
    found = True
    break

if not found:
  print(-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

def seven():
    seven_i = 0
    count = 0
    for i in range(K):
        seven_i += (10**i*7)
        seven_i %= K
        count += 1
        print(seven_i)
        if seven_i % K == 0:
            return count
    return -1

print(seven())

Submission status: Wrong Answer

Solution code:
from math import log10
k = int(input())
dig = int(log10(k)+1)
sp = '7'*dig
frequency = []
ans = 0
for i in range(10**6):
  remainder = int(sp)%k
  if remainder != 0:
    if remainder not in frequency:
      frequency.append(remainder)
      sp += '7'
    else:
      ans = 'No'
      break
  else:
    ans = int(log10(int(sp))+1)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
k = int(input())
val = 7
visited = set()
counter = 1
while len(visited) < k:
    if val in visited:
        print(-1)
        break
    elif val % k == 0:
        print(counter)
        break
    else:
        visited.add(val)
        val = (val * 10 + 7) % k
        counter += 1

Submission status: Wrong Answer

Solution code:
import sys

def main():
    k = int(input())
    m = 7%k
    for i in range(1, k):
        if m == 0:
            print(i)
            exit()
        m = (m*10 + 7)%k
    print(-1)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
K = int(input())
if K % 7 == 0:
    L = 9 * K / 7
else:
    L = 9 * K
if K % 2 == 0 or K % 5 ==0:
    ans = -1
else:
    ans = 1
m = 10 % K
while(ans >= 0):
    if (m == 1):
        break
    m *= 10
    m %= L
    ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
K = int(input())
if K % 7 == 0:
    L = 9 * K / 7
else:
    L = 9 * K
if K % 2 == 0:
    ans = -1
else:
    ans = 1
m = 10 % K
while(ans >= 0):
    if (m == 1):
        break
    m *= 10
    m %= L
    ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
k = int(input())
if k % 2 == 0:
  print(-1)
  sys.exit()
  
# これでは絶対通らないけど、結果として残すため提出
array = [7, 77, 777, 7777, 77777, 777777, 7777777, 77777777, 777777777, 7777777777]

for index, item in enumerate(array):
  if item % k == 0:
    print(index + 1)
    sys.exit()

print(-1)

Submission status: Wrong Answer

Solution code:
N = int(input())

if N < 7:
    print(-1)
    exit()
if N % 2 == 0 or N % 5 == 0:
    print(-1)
    exit()
i = 0
num = 0
while True:
    num = (num * 10 + 7) % N
    i += 1
    if num == 0:
        print(i)
        exit()

K = int(input())

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

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

Submission status: Wrong Answer

Solution code:
N = int(input())

if N < 7:
    print(-1)
    exit()
if N % 2 == 0 or N % 5 == 0:
    print(-1)
    exit()
i = 1
num = 0
while True:
    num = (num * 10 + 7) % N
    if num == 0:
        print(i)
        exit()
    else:
        i += 1

Submission status: Wrong Answer

Solution code:
N = int(input())

if N < 7:
    print(-1)
    exit()
if N % 2 == 0 and N % 5 == 0:
    print(-1)
    exit()
i = 1
num = 0
while True:
    num = (num * 10 + 7) % N
    if num == 0:
        print(i)
        exit()
    else:
        i += 1

Submission status: Wrong Answer

Solution code:
N = int(input())

if N < 7:
    print(-1)
i = 1
num = 0
while True:
    num = (num * 10 + 7) % N
    if num == 0:
        print(i)
        exit()
    else:
        i += 1

Submission status: Wrong Answer

Solution code:
def main():
    k = int(input())
    x = 0
    flag = True
    # 等比数列の和
    # 初項7 公比10 
    # 7 * (1-10**i) / (1-10)
    # これをkで割りきれるか
    # kが7倍数かそうでないかで条件分ける
    mod = 1
    for i in range(1, 10**6+1):
        mod *= 10
        if k % 7 == 0:
            mod = mod % (7*k/9)
            if mod == 1:
                print(i)
                flag = False
                break
        else:
            mod = mod % (9*k)
            if mod == 1:
                print(i)
                flag = False
                break
    if flag:
        print('-1')
        
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
test = int(input())
seven = "7"
while True:
    if test % 2 == 0:
        print(-1)
        break
    if int(seven) >= test:
        if int(seven) % test == 0:
            print(len(seven))
            break
        
    else:
        if test % int(seven) == 0:
            print(len(seven))
            break
    
    seven += "7"

Submission status: Wrong Answer

Solution code:
#C - Repsept
K = input()
K = int(K)

def each_sum(n):#各桁の合計を求める
    s = str(n)
    allay = list(map(int,s))#文字列sを数値リストにして返す
    return(sum(allay)) 
def seven():
    seven_i = 0
    count = 0
    for i in range(1,K):
        seven_i = (7 * ((10**i) -1 )  // 9)
        seven_i %= K
        count += 1
        if seven_i % K == 0:
            return count
    return -1

print(seven())

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
K = int(input())
cnt=0
divK = 7
if K %2 ==0:
	print(-1)
	exit()
while True:
	if divK== 0:
		print(cnt+1)
		break
	divK = (divK*10+7)%K
	cnt +=1

Submission status: Wrong Answer

Solution code:
K = int(input())
cnt=0
divK = 7
if K %2 ==0:
	print(-1)
	exit()
while True:
	if divK %K == 0:
		print(cnt+1)
		break
	divK = divK*10+1
	cnt +=1

Submission status: Wrong Answer

Solution code:
K = int(input())
if K == 7:
    print(1)
else:
    if K % 7 == 0:
        K //= 7
    r = 1
    for i in range(1,K+1):
        if r == 0:
            print(i)
            break
        r += pow(10,i,K)
        #print(r)
        r %= K
    else:
        print(-1)

Submission status: Wrong Answer

Solution code:
K = int(input())
if K % 7 == 0:
    K %= 7
r = 1
for i in range(1,K+1):
    r += pow(10,i,K)
    #print(r)
    r %= K
    if r == 0:
        print(i+1)
        break
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
#abc174_c

k=int(input())

# kの倍数が登場 -> 77...777%k==0となる最小の77の長さは？
if k%2==0:
    print(-1)
    exit()
if k==7:
    print(1)
    exit()

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
K=int(input())
num=7
count = 0
checkK = [0 for j in range(K)]
result = ""

flag = True
while(flag):
    count += 1
    if num==0:
        flag = False
        result = str(count)
    num = (num*10+7)%K
    checkK[num] += 1
    if checkK[num] == 2:
        flag = False
        result = "-1"
print(result)

Submission status: Wrong Answer

Solution code:
k = input()
k = int(k)
f = 0
if 1 <= k and k <= 1000000:
    for i in range(1, 9):
        n = "7"*i
        n = int(n)
        if n%k == 0:
            print(i)
            f = 1
            break
if f == 0:
    print(-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
k = input()
k = int(k)
f = 0
if 1 <= k and k <= 1000000:
    for i in range(1, 8):
        n = "7"*i
        n = int(n)
        if n%k == 0:
            print(i)
            f = 1
            break
if f == 0:
    print(-1)

Submission status: Wrong Answer

Solution code:
k = input()
k = int(k)
f = 0
if 1 <= k and k <= 1000000:
    for i in range(1, 8):
        n = "7"*i
        n = int(n)
        if n%k == 0:
            print(n)
            f = 1
            break
if f == 0:
    print(-1)

Submission status: Wrong Answer

Solution code:
k = input()
k = int(k)
if 1 <= k and k <= 1000000:
    for i in range(1, 8):
        n = "7"*i
        n = int(n)
        if n%k == 0:
            print(n)
        else:
            print(-1)

Submission status: Wrong Answer

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

    print(cnt)

Submission status: Wrong Answer

Solution code:
k=int(input())
if k%2==0 or k%5==0:
    print(-1)
    exit()
ans=1
p=10
pp=pow(9,k-2,k)
while ans<10**7:
    if (p-1)*pp*7%k==0:
        print(ans)
        exit()
    p*=10
    p%=k
    ans+=1

Submission status: Wrong Answer

Solution code:
K = int(input())
r = 1
for i in range(1,K+1):
    r += pow(10,i,K)
    #print(r)
    r %= K
    if r == 0:
        print(i+1)
        break
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
K = int(input())
n = 7
base_m = 7 % K
count = 1

def next_line(n):
    return n * 10 + 7

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

else:
    while(True):
        n = next_line(n)
        m = n % K
        count += 1

        if m == 0:
            print(count)
            break
        
        elif m == base_m:
            print(-1)
            break