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

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    K = int(rl())
    
    if K == 7:
        print(1)
        return
    
    mod = 7
    cnt = 1
    while cnt <= 10 ** 6:
        if mod == 0:
            print(cnt)
            return
        mod = (mod * 10 + 7) % K
        cnt += 1
    print(-1)


if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
k=int(input())

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

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()

n=""
flag=0
for i in range(k):
    n+="7"
    n1=int(n)

    if(n1%k==0):
        flag=1
        break


if(flag==1):
    print(len(n))
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
num = int(input())
seven = 7
col = -1
cnt = 0

for i in range(0, 100):
  if seven % num == 0:
    col = 1
    break
  else:
    seven = (seven*10) + 7
    cnt+=1

if col == 1:
  print(cnt)
else:
  print(col)

Submission status: Wrong Answer

Solution code:
import sys
K = int(input())
i = 0
n = 0
if K<7:
  print('No')
  sys.exit()
while True:
  i += 1
  n += 7*(10**(i-1))
  print(n)
  if n%K == 0:
    print(i)
    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()
for i in range(1,7000):
    if int('7'*i)%K == 0:
        print(i)
        exit()
print(K-1)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import numpy as np
import sys
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect
from scipy.special import comb
import copy
sys.setrecursionlimit(10**6)

# lis_of_lis = [[] for _ in range(N)]


def zz():
    return list(map(int, sys.stdin.readline().split()))


def z():
    return int(sys.stdin.readline())


def S():
    return sys.stdin.readline()[:-1]


def C(line):
    return [sys.stdin.readline() for _ in range(line)]


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


K = z()
if (K == 1):
    print(1)
    exit()
elif (K % 2 == 0):
    print(-1)
    exit()
elif (K == 3):
    print(3)
    exit()
elif (K == 5):
    print(-1)
    exit()
v = '7'
for i in range(1, 1000):
    seven = int(v)
    if (seven % K == 0):
        print(i)
        exit()
    v = v+'7'


if(is_prime(K)):
    print(K-1)
    exit()
else:
    print(-1)
    exit()

Submission status: Wrong Answer

Solution code:
t = int(input())

c = 1
n = 7
f=0
while(n%t !=0):
    c +=1
    n = n*10 + 7
    if(c>=10007):
        print(-1)
        f=1
        break
if(f!=1):
    print(c)

Submission status: Wrong Answer

Solution code:
k = int(input())
import sys
i = 1
amari = 7%k
ama = 7%k
while True:
    if amari%k ==0:
        print(i)
        sys.exit()
    else:
        ama = (ama*10)%k
        amari += ama
        i +=1
    if i == k:
        break
print(-1)

Submission status: Wrong Answer

Solution code:
param_a = int(input())

for i in range(100):
    param_str = '7'*(i+1)
    param_int = int(param_str)
    
    if param_int % param_a == 0:
        param_answer = i+1
        break

try:
    print(param_answer)
except:
    print(-1)

Submission status: Wrong Answer

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

    tmp1 = 7 % K
    tmp2 = tmp1

    for i in range(1, K):
        if tmp2 == 0:
            print(i)
            exit()
        else:
            tmp1 = tmp1 * 10 % K
            tmp2 += tmp1
            tmp2 %= K

    print(-1)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

S=""
count=-1

for i in range(K):
  S += "7"
  M = int(S)
  if( M%K == 0):
    count = i
    break

print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
K = int(input())

p = []
x = 0
a = 0
while True:
    if K%2 == 0:
        a = -1
        break
    a += 1
    x = x + (10**a)*7
    p.append(x)
    if x%K == 0:
        break
print(a)

Submission status: Wrong Answer

Solution code:
#coding:utf-8

k = int(input())

now = 1

if(k%2==0)or(k%5==0):
    print("-1")
elif k == 7:
    print("1")
else:
    if(k%7)==0:
        k = int(k // 7)
    nas = 10 % k
    for i in range(1,k+1):
        now = (now * nas) % k
        if now == 1:
            print("{}".format(i))
            break

Submission status: Wrong Answer

Solution code:
a = int(input())

flag = False
n = 1
if a % 2 == 0:
    print("-1")
    flag = True
else:
    for i in range(1000):
        if int("7"*n) % a == 0:
            flag = True
            break
        else:
            n += 1
    if flag:
        print(n)
    else:
        print(a-1)

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)
elif 7777777 % k == 0:
  print(7)
else:
  print(-1)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
x = int(input())
s = '7'

i=1
b=s*i

if(x%2==0):
    print("-1")

else:	
    while(int(b)%x!=0):
        b=s*i
        i = i+1
        if(int(b)%x==0):
            break
print(i)

Submission status: Wrong Answer

Solution code:
K = int(input())
x = [7, 77, 777, 7777, 77777, 777777]
Count = 0
flag="FALSE"
for i in x:
    Count = Count + 1
    if (i % K)==0:
        flag="TRUE"
        break

if flag=="FALSE":
    Count = -1
print(Count)

Submission status: Wrong Answer

Solution code:
k = int(input())
nums = ""
ans = []
if k % 2 == 1:
    number = 0
    for i in range(15):
        nums += "7"
        if int(nums) % k == 0:
            number = int(nums)
            break
    for i in range(1, k + 1):
        if number % i == 0:
            ans.append(i)
    print(ans.index(k))
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
from sys import stdin
import numpy as np
k = int(stdin.readline().rstrip())

num = 7
ans = 1
while num <= 10**6:
    #処理
    if  num % k == 0 :
      break
    ans = ans + 1
    num = (num * 10) + 7

print(ans)

Submission status: Wrong Answer

Solution code:
K = int(input())

n = "7"*len(str(K))
for i in range(len(str(K)), len(str(K))*10000):
    print(i)
    if int(n) % K == 0:
        print(i)
        break
    n += "7"
else:
    print(-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

while frag==0:
    sevens = sevens + "7"
    n+=1
    if int(sevens)%k==0 or n>1000000:
        frag=1
print(n)

Submission status: Wrong Answer

Solution code:
import sys

n = int(input())

if n < 7:
  print(-1)
  sys.exit()

res = 0
seven = 7

s = 10 **8

for _ in range(s):
  if seven % n == 0:
    print(res + 1)
    sys.exit()
  else:
    res += 1
    seven = int(str(seven) + '7')
print(-1)

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 == 0:
            print(count)
            break
        count += 1
    
    if count == 7:
        print(K - 1)

Submission status: Wrong Answer

Solution code:
k = int(input())
if k==7:
  print(1)
elif k%2==0:
  print(-1)
else:
  cnt = 1
  pre = 7
  while(True):
    surp = (pre*10+7)%k
    cnt += 1
    if surp==0:
      break
    pre = surp
  print(cnt)

Submission status: Wrong Answer

Solution code:
K = int(input())
res = -1
for x in range(1, 7):
	num = '7'*x
	if int(num) % K == 0:
		res = x
		break
print(res)

Submission status: Wrong Answer

Solution code:
def divisors(n):
    d=[]
    for i in range(1,int(n**0.5)+1):
        if n%i==0:
            d.append(i)
            if i!=n//i:
                d.append(n//i)
    d.sort()
    return d

k=int(input())
if k%2==0 or k%5==0:
    print(-1)
    exit()
ans=10**9
for i in range(max(1,k-5),k+5):
    a=divisors(i)
    for j in a:
        if int('7'*j)%k==0:
            ans=min(j,ans)
print(ans)

Submission status: Wrong Answer

Solution code:
K = int(input())

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

num = ""
while True:
    num += "7"
    kazu = int(num)
    print(num)
    if kazu < K:
        continue
    if kazu % K == 0:
        print(len(num))
        break

Submission status: Wrong Answer

Solution code:
import sys

k = int(input())

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


ans = 1
n = "7"
for _ in range(8000):
    if int(n) % k == 0:
        print(ans)
        sys.exit()
    else:
        n += "7"
        ans += 1
else:
    print(k - 1)

Submission status: Wrong Answer

Solution code:
param_a = int(input())

for i in range(8):
    param_str = '7'*(i+1)
    param_int = int(param_str)
    
    if param_int % param_a == 0:
        param_answer = i+1
        break

try:
    print(param_answer)
except:
    print(-1)

Submission status: Wrong Answer

Solution code:
a = int(input())
b = 7
for n in range(15):
    if n != 0:
        b = str(b) + str(7)
        b = int(b)
    if b%a == 0:
        print(n+1)
        break

Submission status: Wrong Answer

Solution code:
def main():
    K = int(input())
    if K % 2 == 0 or K % 5 == 0:
        print(-1)
    elif str(K).count('7') == len(str(K)):
        print(len(str(K)))
    else:
        ANS = -1
        A = 0
        for i in range(15):
            A = 10*A + 7
            if A % K == 0:
                ANS = i + 1
                break
        if ANS == -1:
            ANS = K - 1
        print(ANS)
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys

K = input()
tmp = len(K)
K = int(K)

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

flag = 0
num = 7
count = tmp

for i in range(tmp):
    num = num * 10 + 7

while flag == 0:
    count += 1
    if num % K == 0:
        print(count)
        sys.exit()
    else:
        num = (num % K) * 10 + 7

Submission status: Wrong Answer

Solution code:
k=int(input())
c=1
m='7'
if k%2==0:
    print(-1)
else:
    l=len(str(k))
    for i in range(l):
        c+=1
        m=m+'7'
    while True:

        if int(m)%k==0:
            print(c)
            break
        m=m+'7'
        c+=1

Submission status: Wrong Answer

Solution code:
import sys

n = int(input())

if n < 7:
  print(-1)
  sys.exit()

res = 0
seven = 7

s = 10 **6

for _ in range(s):
  if seven // n == 0:
    print(res + 1)
  else:
    res += 1
    seven = int(str(seven) + '7')

Submission status: Wrong Answer

Solution code:
k = int(input())
t = '7'
i = 0
if k % 2 == 0:
    print(-1)
elif (set(str(k))) == {'0', '1'} or k % 7 == 0:
    while(1):
        s = int(t)
        if s % k == 0:
            ans = i+1
            break
        t += '7'
        i += 1
    print(ans)
else:
    print(k-1)

Submission status: Wrong Answer

Solution code:
n=int(input())
num=7
ans=-1
if n%2==0:
    print(-1)
else:
    flag=0
    for i in range(1,1000):
        if flag==1:
            break
        for j in range(1,100):
            if num%n==0:
                flag=1
                #print(i,j)
                ans=(i-1)*1000 + j
                break
            num=num*10+7

    print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())

sm=0
work=7
for i in range(1,n):
    sm+=work
    while sm>=n:
        sm-=n
    if sm==0 :
        print(i)
        break
    work*=10
    work%=n
else : print(-1)

Submission status: Wrong Answer

Solution code:
n=int(input())
if(n%2==0):
  print(-1)
elif(n==999983):
  print(999982)
elif(n==101):
  print(4)
else:
  print(-1)

Submission status: Wrong Answer

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

for i in range(6):
    N += 7 * 10**i
    if N % K == 0:
        print(count)
        break
    count += 1
    
if count == 7:
    print(K - 1)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import numpy as np
import re

k = int(input())

s = 0
cnt = 0
flg = False

while (cnt < 1e15):
    cnt += 2

    if k < 7:
        flg = False
        break

    elif k % 2 == 0:
        flg = False
        break

    k_str = str(k * cnt)

    pattern = '7+'

    result = re.match(pattern, k_str)

    if result is not None:
        l = result.span()[1]
    
        if l == len(k_str):
            flg = True
            break

if flg == True:
    print(len(k_str))
else:
    print(-1, cnt)

Submission status: Wrong Answer

Solution code:
def main():

    K = int(input())
    # N, D = map(int, input().split())
    # A = [int(i) for i in input().split()]

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

    ans = 1
    N = 7
    for i in range(10 ** 6):
        # print(f"{N = }")
        N %= K
        if not N:
            break
        N = N * 10 + 7
        ans += 1

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#coding:utf-8

k = int(input())

nas = 10 % k
now = 1

if(k%2==0)or(k%5==0):
    print("-1")
else:
    for i in range(1,k):
        now = (now * nas) % k
        if now == 1:
            print("{}".format(i))
            break

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
num = int(input())
val = 7
cnt = 1
while True:
    val %= num
    if cnt >= num: 
        cnt = -1
        break
    if val == 0: break
    val *= 10
    val += 7
    cnt += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
n=int(input())
if(n%2==0):
  print(-1)
elif(n==999983):
  print(999982)
elif(n==101):
  print(4)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
K = int(input())
amari = 0
res = set()
tmp = 7
flag = False
for i in range(10**6):
    if i == 0:
        if tmp % K == 0:
            flag = True
        else:
            tmp = tmp % K
            res.add(tmp)
            amari += tmp
    else:
        tmp = (tmp * 10) % K
        amari += tmp
        amari = amari % K
        if amari == 0:
            flag = True
        if flag:
            break
if flag:
    print(i + 1)
else:
    print(-1)

Submission status: Wrong Answer

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

n = 0
r = -1
for i in range(7):
    n = n*10 + 7
    b = n % k
    if(b == 0):
        r = i+1
        break

print(r)

Submission status: Wrong Answer

Solution code:
k = int(input())
if(k%2==0):
  print("-1")
else:
  i = 1
  while True:
    m = 7
    if(m%k==0):
      print(i)
      break
    if(i>10000000):
      print("-1")
      break
    m = m*10 + 7
    i += 1

Submission status: Wrong Answer

Solution code:
#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

k = int(input())

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

elif is_prime(k):
    print(k - 1)

else:
    flag = 0
    arr = '7'
    cnt = 1
    while flag != 1:
        if int(arr) % k == 0:
            print(cnt)
            flag = 1
        else:
            cnt += 1
            arr += '7'

Submission status: Wrong Answer

Solution code:
k = int(input())

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

if n%k == 0:
  print(1)
  exit()

while i < 10**6:
  i += 1
  n = int('1'*i)
  if n%k == 0:
    print(i)
    exit()

print(-1)

Submission status: Wrong Answer

Solution code:
K = int(input())
Ali = []

for i in range(1,int(K**0.5+1)):
  if (K-1)%i==0:
    Ali.append(i)
    Ali.append((K-1)//i)
    
Ali.sort()

for i in Ali:
  s = 7
  for j in range(i-1):
    s = (s*10+7)%K
  if s%K == 0:
    print(i)
    exit()
  
print(-1)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline


def readstr():
    return input().strip()


def readint():
    return int(input())


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


def readstrs():
    return input().split()


def main():
    K = readint()
    if not K % 2:
        print(-1)
    elif not K % 7:
        print(1)
    else:
        d = 7 % K
        s = set()
        for i in range(1, 10 ** 6 + 1):
            s.add(d)
            d = (d * 10 + 7) % K
            if not d:
                print(i + 1)
                sys.exit()
            elif d in s:
                print(-1)
                sys.exit()
        print(-1)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
K = int(input())
count = 1
t=0
if K % 2!=0:
    while t >=0:
        t = t * 10 +7
        #print(t)
        if t % K ==0:
            print(count)
            break
        if len(str(t)) >=100:
            count = K-1
            print(count)
            break
        count+=1
        
    
elif K%2 == 0:
    print(-1)

Submission status: Wrong Answer

Solution code:
k = int(input())

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

for i in range(1, 11):
    if int('7'*i) % k == 0:
        print(i)
        break
else:
    print(k - 1)

Submission status: Wrong Answer

Solution code:
n = int(input())
 
if n % 2 == 0:
    print("-1")
    exit()
 
for i in range(1,1000):
    if int('7' * i) >= n:
        if int('7' * i)%n == 0:
            print(i)
            exit()
 
print("-1")

Submission status: Wrong Answer

Solution code:
n=int(input())

sm=0
work=7
for i in range(1,n):
    sm+=work
    while sm>n:
        sm-=n
    if sm==n :
        print(i)
        break
    work*=10
    work%=n
else : print(-1)

Submission status: Wrong Answer

Solution code:
k = int(input())

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

Submission status: Wrong Answer

Solution code:
k = int(input())

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

a = 7
counter = 1

for i in range(k):
    r = a%k
    if(r == 0):
        print(counter)
        break
    else:
        counter += 1
        a = 10*r + 7%k

Submission status: Wrong Answer

Solution code:
k = int(input())
if(k%2==0):
  print("-1")
else:
  i = 1
  while True:
    m = 7
    if(m%k==0):
      ans = i
      print(ans)
      break
    if(i>1000000):
      print("-1")
      break
    m = m*10 + 7
    i += 1

Submission status: Wrong Answer

Solution code:
k = int(input())
#a,b = map(int,input().split())
#a_L = list(map(int,input().split()))
ks = str(k)

n = len(ks)

if n-1 != 0:
    sevn = "7"*(n-1)
else:
    sevn = "7"
    n = 2
#print(sevn)


for i in range(n-1,n-1+10**4+1):
    tmp = int(sevn)
    if tmp%k==0:
        print(i)
        exit()
    sevn += "7"
    #i += 1

print(-1)

Submission status: Wrong Answer

Solution code:
n = "7"
k = int(input())
cons = int(10e6) + 7
count = 1
for i in range(cons):
    n_int = int(n)
    if k % n_int == 0 or n_int % k == 0:
        print(count)
        break
    else:
        count += 1
        n += "7"
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
k = int(input())
t = '7'
i = 0
if k % 2 == 0:
    print(-1)
elif (set(str(k))) == {'0', '1'}:
    while(1):
        s = int(t)
        if s % k == 0:
            ans = i+1
            break
        t += '7'
        i += 1
    print(ans)
else:
    print(k-1)

Submission status: Wrong Answer

Solution code:

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
k = int(input())
sen = []
for i in range(1,7):
    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:
    print(-1)
elif m:
    print(k-1)
else:
    w = 1
    # 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())
count = 0
for sev in range(10**3):
  sev = sev *10 + 7
  count += 1
  if sev % K == 0:
    continue
  elif count >10**6:
    count = -1
    continue
print(count)

Submission status: Wrong Answer

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

import math

def main():
    k = int(input())
    k_max = k * k

    base = 0
    for i in range(100):
        base = base * 10 + 7
        if base > k_max:
            print(-1)
            break
        if (base % k) == 0:
            print(i + 1)
            break

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
k = int(input())
if(k==7):
    print(1)
    exit()
if(k%2==0):
    print(-1)
    exit()
x = 7
ans = None
for i in range(2,10**6+5):
    nex_x = 10*x+7
    nex_x = nex_x%k
    if(nex_x==0):
        ans = i
        break
    x = nex_x
    
if(ans is None):
    print(-1)
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
k = int(input())
if(k&2==0):
  print("-1")
else:
  i = 1
  while True:
    m = 7
    if(m%k==0):
      ans = i
      print(ans)
      break
    if(i>1000000):
      print("-1")
      break
    m = m*10 + 7
    i += 1

Submission status: Wrong Answer

Solution code:
K = int(input())

X = 7
count = 1

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

print(-1)

Submission status: Wrong Answer

Solution code:
K=int(input())

from collections import defaultdict
app = defaultdict(lambda: False)
broken=False
for n in range(1,K):
    if n==1:
        amari = 7%K
    else:
        amari = (amari + 7*pow(10,n-1,K) )%K
    
    if amari==0:
        broken=True
        break
    if app[amari]:
        broken=True
        break
    else:
        app[amari]=True
if broken:
    print(n)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
k = input()

a = '7'
if len(k)!=1:
    for i in range(len(k)-1):
        a += '7'
print(a)

if int(k) % 2 == 0:
    print(-1)
else:
    for i in range(10 ** 6):
        if int(a) % int(k) == 0:
            print(len(a))
            exit()
        else:
            a += '7'

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

k = int(input())

res = 1
a = 7
p = 7

d = set()

while True:
    if a == 0:
        print(res)
        exit()
    p = p*10%k
    a = (a+p)%k
    res += 1
    if a in d:
        print(-1)
        exit()
    d.add(a)
print(-1)

Submission status: Wrong Answer

Solution code:
n = int(input())
if n%2==0:
  print(-1)
  exit()
seven = 7
while seven<=n*n:
  if n<=seven and seven%n==0:
    print(len(str(seven)))
    exit()
  seven = int(str(seven)+'7')
print(-1)

Submission status: Wrong Answer

Solution code:
n=int(input())

sm=0
work=7
for i in range(1,n):
    sm+=work
    if sm==n :
        print(i)
        break
    elif sm>n :
        sm-=n    
    work*=10
    work%=n

else : print(-1)

Submission status: Wrong Answer

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

ten = 1
now = 0
for i in range(10**8):
    x = (ten*7)%k
    now = (now+x)%k
    if now == 0:
        print(i+1)
        exit()
    ten = ten*10%k

Submission status: Wrong Answer

Solution code:
def main():
    K = int(input())
    if K % 2 == 0 or K % 5 == 0:
        print(-1)
        return
    cnt = 1
    tmp = 7
    while tmp != 0:
        tmp = tmp * 10 + 7
        tmp %= K
        cnt += 1

    print(cnt)

main()

Submission status: Wrong Answer

Solution code:
k = int(input())
#a,b = map(int,input().split())
#a_L = list(map(int,input().split()))
ks = str(k)

n = len(ks)

if n-1 != 0:
    sevn = "7"*(n-1)
else:
    sevn = "7"
    n = 2
#print(sevn)


for i in range(n-1,n-1+10**2+1):
    tmp = int(sevn)
    if tmp%k==0:
        print(i)
        exit()
    sevn += "7"
    #i += 1

print(-1)

Submission status: Wrong Answer

Solution code:
K = int(input())
num_7 = 1
if K % 2 == 0:
  print(-1)
else:
  n = int("7" * num_7)
  if n % K == 0:
    print(num_7)
  num_7 += 1

Submission status: Wrong Answer

Solution code:
K=int(input())

from collections import defaultdict
app = defaultdict(lambda: False)
broken=False
for n in range(1,K+1):
    if n==1:
        amari = 7%K
    else:
        amari = (amari + 7*pow(10,n-1,K) )%K

    if amari==0:
        broken=True
        break
    if app[amari]:
        broken=True
        break
    else:
        app[amari]=True
if broken:
    print(n)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
lst=['7'*k for k in range(1, 1111)]
k=int(input())
i=0
ok=False
for _ in lst:
    p=int(lst[i])
    if p%k==0:
        ok=True
        print(i+1)
        break
    i+=1
    
if ok==False:
    print(-1)

Submission status: Wrong Answer

Solution code:
k = int(input())
cnt, amari = 0, 0
a = []
while True:
    cnt += 1
    amari = (amari*10+7)%k
    if amari in a:
        ans = -1
        break
    elif amari == 0:
        ans = cnt
        break
    else:
        a.append(amari)
        print(amari)

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)
elif 7777777 % k == 0:
    print(7)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
k=int(input())
a='7'*k
if k%2==0:
    print(-1)
else:
    while True:
        if int(a)%k==0:
            print(len(a))
            break
        a+='7'

Submission status: Wrong Answer

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

k = inp()
if k%2 == 0:
    print(-1)
    quit()
now = 0
for i in range(k+10000):
    now += pow(10,i+1,k)*7
    now %= k
    if now%k == 0:
        print(i+1)
        quit()
print(-1)

Submission status: Wrong Answer

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

ten = 1
now = 0
for i in range(10**7):
    x = (ten*7)%k
    now = (now+x)%k
    if now == 0:
        print(i+1)
        exit()
    ten = ten*10%k

Submission status: Wrong Answer

Solution code:
N = int(input())
cou = 1
if N % 2 == 0:
  cou = -1
else:
  t = "7"
  co = int(t) / N 
  while co.is_integer()== False:
    cou += 1
    t += "7"
    co = int(t) / N
print(cou)

Submission status: Wrong Answer

Solution code:
k = int(input())
if k == 1 or k == 7:
    print(1)
count = 1
tmp = 7
s = [0 for i in range(k+8)]
while True:
    if s[tmp] != 0:
        print(-1)
        exit()
    s[tmp]+=1
    tmp*=10
    tmp+=7
    tmp %= k
    count+=1
    if tmp == 0:
        print(count)
        exit()

Submission status: Wrong Answer

Solution code:
K = int(input())
count = 0
for sev in range(10**3):
  sev = sev *10 + 7
  count += 1
  if sev % K == 0:
    pass
  elif count >10**6:
    count = -1
    pass
print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#

import sys
from math import gcd
input=sys.stdin.readline

def main():
    K=int(input())
    if K%2==0:
        print(-1)
        exit()
    if K==5:
        print(-1)
    s=set()
    r=7%K
    rsum=r
    s.add(r)
    for i in range(10**6):
        if rsum==0:
            print(i+1)
            exit()
        r=(r*10)%K
        if r in s:
            break
        s.add(r)
        rsum=(rsum+r)%K
    print((i+1)*K/gcd(rsum,K))
    
    
    
if __name__=="__main__":
    main()

Submission status: Wrong Answer

Solution code:
k = int(input())
a = [7, 77, 777, 7777, 77777, 777777, 7777777]
r = -1
for i in range(7):
    b = a[i] % k
    if(b == 0):
        r = i+1
        break

print(r)

Submission status: Wrong Answer

Solution code:
q = int(input())
a = 0
f = 0
for i in range(10**6):
    a += 10**i * 7 
    if a % q == 0 and a > q :
        f = 1
        break

a = str(a)
if f == 0:
    print(-1)
if f == 1:
    print(len(a))

Submission status: Wrong Answer

Solution code:
k = int(input())
#a,b = map(int,input().split())
#a_L = list(map(int,input().split()))
ks = str(k)

n = len(ks)

if n-1 != 0:
    sevn = "7"*(n-1)
else:
    sevn = "7"
#print(sevn)


for i in range(n-1,n-1+10**5+1):
    tmp = int(sevn)
    if tmp%k==0:
        print(i)
        exit()
    sevn += "7"
    #i += 1

print(-1)

Submission status: Wrong Answer

Solution code:
k=int(input())
cnt=1
flag=True
if k%2==0:
    print(-1)
else:
    keta=10
    tmp=0
    while cnt<=10**6:
        tmp+=pow(keta,cnt-1,k)*7
        if tmp%k==0:
            print(cnt)
            flag=False
            break
        cnt+=1
if flag:
    print(-1)