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:
limit = pow(10, 7)
K = int(input())
num = "7"
if K % 2 == 0 or K % 5 == 0:
    print (-1)
else:
    total = 0
    flag = False
    for i in range(limit + 1):
        total = (total * 10 + 7) % K
        if total == 0:
            flag = True
            break
    if flag:
        print (i)
    else:
        print(-1)

Submission status: Wrong Answer

Solution code:
limit = pow(10, 6)
K = int(input())
num = "7"
if K % 2 == 0:
    print (-1)
else:
    # if the num is smaller than K, then add "7"
    for j in range(K):
        if int(num) < K:
            num += "7"
        else:
            break
    flag = False
    ok = "7"
    ans = ""
    for i in range(limit + 1):
        if all(c in ok for c in str(K * i)) and (K * i) % 7 == 0:
            # print(K * i, i, len(str(K * i)))
            flag = True
            ans = len(str(K * i))
            break
        num += "7"
    if flag:
        print (ans)
    else:
        print(-1)

Submission status: Wrong Answer

Solution code:
k = int(input())
a = [None]*1000001
a[1]=7%k
n=0

for i in range(2,k+1):
    a[i]=(a[i-1]*10+7)%k
    if a[i]==0 and n==0:
        print("{}".format(i))
        n=1
if n==0:
    print("-1")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from sys import stdin
input = stdin.readline
ri = lambda : int(input())
ril = lambda : list(map(int, input().split()))

def main():
  K = ri()
  m = 0
  ans = -1
  for i in range(K):
    m = (10 * m + 7) % K
    if m == 0:
      ans = i
      break
  print(ans)

if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
k = int(input('k='))
num = 7
count = 1

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

Submission status: Wrong Answer

Solution code:
N = int(input())

mod_first = 7 % N
mod_next = mod_first * 11

if mod_first == 0:
    print("1")
    exit()
if mod_next == 0:
    print("2")
    exit()

for i in range(1000000):
    mod_next = (mod_next * 10 + mod_first) % N
    if mod_next == 0:
        print(i + 3)
        exit()

print("-1")

Submission status: Wrong Answer

Solution code:
N = int(input())

mod_first = 7 % N
mod_next = mod_first * 11

if mod_first == 0:
    print("1")
    exit()
if mod_next == 0:
    print("2")
    exit()

for i in range(1000000):
    mod_next = (mod_next * 10 + mod_first) % N
    if mod_next == 0:
        print(i + 3)
        break
else:
    print("-1")

Submission status: Wrong Answer

Solution code:
def main():
    k = int(input())
    init = 7%k
    an = [init]
    for _ in range(k):
        a = an[-1]
        an.append((10*a+7) % k)

    for ind, a in enumerate(an):
        if a==0:
            print(ind)
            return
    print(-1)
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
K=input()
keta = len(K)
k=int(K)
if k%2==0:
  print(-1)
else:
  seven = "7"*keta
  s = int(seven)
  ans=keta-1
  for _ in range(2*k):
    ans+=1
    s = s%k
    if s==0:
      print(ans)
      break
    else:
      s = s*10+7

Submission status: Wrong Answer

Solution code:
K=input()
keta = len(K)
k=int(K)
if k%2==0:
  print(-1)
else:
  seven = "7"*keta
  s = int(seven)
  ans=keta-1
  for _ in range(k):
    ans+=1
    s = s%k
    if s==0:
      print(ans)
      break
    else:
      s = s*10+7

Submission status: Wrong Answer

Solution code:
K=input()
keta = len(K)
k=int(K)
if k%2==0:
  print(-1)
else:
  seven = "7"*keta
  s = int(seven)
  ans=0
  while (1):
    ans+=1
    s = s%k
    if s==0:
      print(ans)
      break
    else:
      s = s*10+7

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
k=int(input())
l=[]
x=7%k
if x == 0:
  print(1)
  sys.exit()
for i in range(2,k+1):
  x=7%k
  num=(x*10+7)%k
  x=num
  l.append(num)
  if num==0:
    print(i)
    break
if 0 not in l:
  print(-1)

Submission status: Wrong Answer

Solution code:
import sys
k=int(input())
l=[]
x=7%k
if x == 0:
  print(1)
sys.exit()
for i in range(2,k+1):
  x=7%k
  num=(x*10+7)%k
  x=num
  l.append(num)
  if num==0:
    print(i)
    break
if 0 not in l:
  print(-1)

Submission status: Wrong Answer

Solution code:
k=int(input())
l=[]
for i in range(1,k+1):
  x=7%k
  num=(x*10+7)%k
  x=num
  l.append(num)
  if num==0:
    print(i)
    break
if 0 not in l:
  print(-1)

Submission status: Wrong Answer

Solution code:
k=int(input())
x=7%k
l=[]
for i in range(2,k+1):
  num=(x*10+7)%k
  x=num
  l.append(num)
  if num==0:
    print(i)
    break
if 0 not in l:
  print(-1)

Submission status: Wrong Answer

Solution code:
k=int(input())
x=7%k
l=[]
for i in range(1,k+1):
  num=(x*10+7)%k
  x=num
  l.append(num)
  if num==0:
    print(i)
    break
if 0 not in l:
  print(-1)

Submission status: Wrong Answer

Solution code:
k=int(input())
x=7%k
l=[]
i=1
while len(l)==len(set(l)):
  num=(x*10+7)%k
  x=num
  l.append(num)
  i+=1
  if num==0:
    print(i)
    break
if 0 not in l:
  print(-1)

Submission status: Wrong Answer

Solution code:
K = int(input())
used = set()
pos = 1
v = 0

while 1:
    v += 10*v+7
    v %= K
    if v==0:
        print(pos)
        break
    if v in used:
        print(-1)
        break
    used.add(v)
    pos += 1

Submission status: Wrong Answer

Solution code:
from sys import stdin
K = int(stdin.readline().rstrip())
def main(K):
  a=0
  for i in range(1,K):
    a = ((10%K) * a + 7)%K
    if a == 0:
      return i
  return -1
print(main(K))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
k = int(input())
lis = []
c = 0
a = 0
while(True):
    a = (a*10 + 7) & k
    if a == 0:
        print(c+1)
        quit()
    if c > k:
        print(-1)
        quit()
    c += 1

Submission status: Wrong Answer

Solution code:
K = int(input())
ans = 0
if K%2 == 0:
    print(-1)
else: 
    cnt = int(len(str(K)))+1
    while(ans<1):
        tmp =  int("7"*cnt)
        if tmp % K == 0:
            ans =int("7"*cnt)
            break
        else:
            cnt += 1
    print(cnt)

Submission status: Wrong Answer

Solution code:
#atcoder template
def main():
    import sys
    imput = sys.stdin.readline
    #文字列入力の時は上記はerrorとなる。
    #ここにコード
    #input
    k = int(input())

    #output
    mod = 0
    l = len(str(k))
    # %%
    if k % 2 == 0:
        print(-1)
    else:
        for i in range(l+1):
            mod += 7*pow(10, i, k) % k
            mod %= k
            if mod == 0:
                print(i+1)
                break

    #N = 1のときなどcorner caseを確認！
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
k = int(input())
m = 0

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

Submission status: Wrong Answer

Solution code:
def main():

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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
k = int(input())
mod_k = [0] * (k+2)
mod_k[1] = 7 % k
if k == 7:
    print(1)
    sys.exit()
for i in range(2,k+1):
    nex = (mod_k[i-1]*10+7) % k
    if nex == 0:
        print(i)
        sys.exit()
    mod_k[i] = nex
print(-1)

Submission status: Wrong Answer

Solution code:
import sys
k = int(input())
mod_k = [0] * (k+1)
mod_k[1] = 7 % k
if k == 7:
    print(1)
    sys.exit()
for i in range(2,k+1):
    nex = (mod_k[i-1]*10+7) % k
    if nex == 0:
        print(i)
        sys.exit()
    mod_k[i] = nex
print(-1)

Submission status: Wrong Answer

Solution code:
def c_repsept_totient():
    def totient_function(n):
        """正整数 n に対して、n と互いに素な n 以下の正整数の個数"""
        ret, tmp = n, n

        i = 2
        while i * i <= n:
            if tmp % i == 0:  # i は n の素因数である
                ret -= ret // i
                while tmp % i == 0:  # 素因数の指数に興味はないので、割り続ける
                    tmp //= i
            i += 1
        if tmp > 1:
            ret -= ret // tmp
        return ret

    def divisor_list(n):
        """n の正の約数のリスト"""
        ret = set()
        for k in range(1, int(n**0.5) + 1):
            if n % k == 0:
                ret.update({k, n // k})
        return sorted(ret)

    K = int(input())
    L = K // 7 if K % 7 == 0 else K

    for d in divisor_list(totient_function(L)):
        if pow(10, d, L) == 1:
            return d
    return -1

print(c_repsept_totient())

Submission status: Wrong Answer

Solution code:
def c_repsept_totient():
    def totient_function(n):
        """正整数 n に対して、n と互いに素な n 以下の正整数の個数"""
        ret, tmp = n, n

        i = 2
        while i * i <= tmp:
            if tmp % i == 0:  # i は n の素因数である
                ret -= ret // i
                while tmp % i == 0:  # 素因数の指数に興味はないので、割り続ける
                    tmp //= i
            i += 1
        if tmp > 1:
            ret -= ret // tmp
        return ret

    def divisor_list(n):
        """n の正の約数のリスト"""
        ret = set()
        for k in range(1, int(n**0.5) + 1):
            if n % k == 0:
                ret.update({k, n // k})
        return sorted(ret)

    K = int(input())
    L = K // 7 if K % 7 == 0 else K

    for d in divisor_list(totient_function(L)):
        if pow(10, d, L) == 1:
            return d
    return -1

print(c_repsept_totient())

Submission status: Wrong Answer

Solution code:
def c_repsept_totient():
    def totient_function(n):
        """正整数 n に対して、n と互いに素な n 以下の正整数の個数"""
        ret, tmp = n, n

        i = 2
        while i * i <= tmp:
            if tmp % i == 0:  # i は n の素因数である
                ret //= i
                while tmp % i == 0:  # 素因数の指数に興味はないので、割り続ける
                    tmp //= i
            i += 1
        if tmp > 1:
            ret -= ret // tmp
        return ret

    def divisor_list(n):
        """n の正の約数のリスト"""
        ret = set()
        for k in range(1, int(n**0.5) + 1):
            if n % k == 0:
                ret.update({k, n // k})
        return sorted(ret)

    K = int(input())
    L = K // 7 if K % 7 == 0 else K

    for d in divisor_list(totient_function(L)):
        if pow(10, d, L) == 1:
            return d
    return -1

print(c_repsept_totient())

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!

K = int(input())

Sequence = 0
flag = 0
for i in range(K) : 
    Sequence += 7*(10**i)

    if Sequence % K == 0 : 
        flag = 1
        break

if flag == 1 : 
    print(K)
else : 
    print(-1)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!

K = int(input())

i = 0
Sequence = 0
Surplus_list = []
while(True) : 
    while(True) : 
        Sequence += 7*(10**i)
        if Sequence >= K : 
            break
        i += 1
    
    if Sequence % K == 0 : 
        flag = 1
        break
    else : 
        if K in Surplus_list : 
            flag = 0
            break
        else : 
            Surplus_list.append(K)
            
    i += 1
    
if flag == 1 : 
    print(K)
else : 
    print(-1)

Submission status: Wrong Answer

Solution code:
import sys
import math
import time
sys.setrecursionlimit(int(1e6))
if False:
    dprint = print
else:
    def dprint(*args):
        pass

k = list(map(int, input().split()))[0]

modk = 7 % k
i = 1
while(i < k):
    if modk == 0:
        print(i)
        exit()

    i += 1
    modk = (modk * 10 + 7) % k
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
import math

k=input()
k=int(k)

N = 20
res = -1
for i in range(1,N):
 str7 = "" 
 for ix in range(i):
  str7 += "7"
# print(str7) 
# if str7 != "":
 n7 = int(str7)
# print(i)
# print(n7)
 if n7%k == 0:
  res = i
  break

#print("res")
print(res)

Submission status: Wrong Answer

Solution code:
import sys
import math
import time
sys.setrecursionlimit(int(1e6))
if False:
    dprint = print
else:
    def dprint(*args):
        pass

k = list(map(int, input().split()))[0]

if (k % 7 == 0):
    l = 9*k/7
else:
    l = 9*k
dprint('k, l = ', k, l)

i = 1
n = 10
while(i < k):
    m = n % l
    if (m == 1): # (10^i mod L = 1)
        print(i)
        exit()
    dprint('i, n, m = ', i, n, m)

    i = i + 1
    n = m * 10
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
from decimal import Decimal
K = int(input())

x = Decimal(7 % K)

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

Submission status: Wrong Answer

Solution code:
K = int(input())

x = 7 % K

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

Submission status: Wrong Answer

Solution code:
K = int(input())

x = 7 % K

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

Submission status: Wrong Answer

Solution code:
K = int(input())

x = 7 % K

for i in range(1, K):
  if x == 0:
    print(i)
    exit()
  print("x = " + str(x))
  x = (x * 10 + 7) % K
  
print('-1')

Submission status: Wrong Answer

Solution code:
T=int(input())
if T%7==0:
  K=T/7
else: K=T
A=int(10%K)
cnt=1
while A != 1:
  cnt+=1
  A=int((10*A)%K)
print(int(cnt))

Submission status: Wrong Answer

Solution code:
import time
k = int(input())
kk = k
n = 7
c = 1
t1 = time.time() 
t2 = time.time()
while (t2-t1) <= 1.8:
  if k%7 == 0:
    s = str(k)
    if all(x=="7" for x in s):
      print(len(s))
      break
  k+=kk
  t2 = time.time()

if (t2-t1) > 1.8:
  print(-1)

Submission status: Wrong Answer

Solution code:
import time
k = int(input())
n = 7
c = 1
t1 = time.time() 
t2 = time.time()
while (t2-t1) <= 1.8:
  if n%k == 0:
    print(c)
    break
  else:
    n = int(str(n)+"7")
    c+=1
    t2 = time.time()

if (t2-t1) > 1.8:
  print(-1)

Submission status: Wrong Answer

Solution code:
import time
k = int(input())
n = 7
c = 1
t1 = time.time() 
t2 = time.time()
while (t2-t1) <= 1:
  if n%k == 0:
    print(c)
    break
  else:
    n = int(str(n)+"7")
    c+=1
    t2 = time.time()

if (t2-t1) > 1:
  print(-1)

Submission status: Wrong Answer

Solution code:
k = int(input())
dp = [0 for _ in range(k+100)]
dp[0]=  7
good = False
for i in range(1, k+1):
    dp[i] = (dp[i-1] * 10 + 7) % k
    if dp[i] % k == 0:
        print(i+1)
        good = True
        break
if not(good):
    print(-1)

Submission status: Wrong Answer

Solution code:
k = int(input())
dp = [0 for _ in range(k+100)]
dp[0]=  7
good = False
for i in range(1, k+100):
    dp[i] = (dp[i-1] * 10 + 7) % k
    if dp[i] % k == 0:
        print(i+1)
        good = True
        break
if not(good):
    print(-1)

Submission status: Wrong Answer

Solution code:
#C-respect
K = int(input())
count = 1
a = 7

for i in range(K):
    if a == 0:
        print (count)
        exit ()
    else:
        a = (10 * a + 7) % K
        count += 1

print (-1)

Submission status: Wrong Answer

Solution code:
#C-respect
K = int(input())
count = 1
a = 7 % K

for i in range(K):
    a = (10 * a + 7) % K
    if a == 0:
        print (count)
        exit ()
    else:
        count += 1

print (-1)

Submission status: Wrong Answer

Solution code:
#C-respect
K = int(input())
count = 1
a = 7 % K

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

Submission status: Wrong Answer

Solution code:
K = int(input())

max_num = 10 ** 20

i = 1
s = 0
while s < max_num:
  s = (7 * (10**i) - 7) // 9
  if s % K == 0:
    print(i)
    exit()
  i += 1
print('-1')

Submission status: Wrong Answer

Solution code:
K = int(input())

max_num = 10 ** 9

i = 1
s = 0
while s < max_num:
  s = (7 * (10**i) - 7) // 9
  if s % K == 0:
    print(i)
    exit()
  i += 1
print('-1')

Submission status: Wrong Answer

Solution code:
from __future__ import print_function

import sys
sys.setrecursionlimit(500000)

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction

import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return

# from fractions import gcd
# from math import gcd

# def lcm(n, m):
#     return int(n * m / gcd(n, m))


# def coprimize(p, q):
#     common = gcd(p, q)
#     return (p // common, q // common)


# def find_gcd(list_l):
#     x = reduce(gcd, list_l)
#     return x


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


mod=1000000007
def combinations_count_mod(n, r):
    r = min(r, n - r)
    numer = reduce(lambda x,y: x*y%mod, range(n, n - r, -1), 1)
    denom = pow( reduce(lambda x,y: x*y%mod, range(1, r + 1), 1) , mod-2, mod)
    return numer * denom % mod


def solve(k):
    dp=[0 for _ in range(k+100)]
    for i in range(1,k):
        dp[i]=(dp[i-1]*10+7)%k
        if dp[i]%k==0:
            return (i)
    return -1

def main():
    k = int(input().strip())
    print(solve(k))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from __future__ import print_function

from functools import reduce
from operator import mul
from collections import Counter
from collections import deque
from itertools import accumulate
from queue import Queue
from queue import PriorityQueue as pq
from heapq import heapreplace
from heapq import heapify
from heapq import heappushpop
from heapq import heappop
from heapq import heappush
import heapq
import time
import random
import bisect
import itertools
import collections
from fractions import Fraction
import fractions
import string
import math
import operator
import functools
import copy
import array
import re
import sys
sys.setrecursionlimit(500000)


input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return

# from fractions import gcd
# from math import gcd

# def lcm(n, m):
#     return int(n * m / gcd(n, m))


# def coprimize(p, q):
#     common = gcd(p, q)
#     return (p // common, q // common)


# def find_gcd(list_l):
#     x = reduce(gcd, list_l)
#     return x


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


mod = 1000000007


def combinations_count_mod(n, r):
    r = min(r, n - r)
    numer = reduce(lambda x, y: x*y % mod, range(n, n - r, -1), 1)
    denom = pow(reduce(lambda x, y: x*y % mod, range(1, r + 1), 1), mod-2, mod)
    return numer * denom % mod


# def f(a_init, n):
#     # n_init=7
#     if n == 0:
#         return (a_init*10 + a_init)%K
#     else:
#         return (f(a_init, n-1)*10 + a_init)%K

a_init=7
def solve(K):
    if K%2==0 or K%5==0:
        return -1
    else:
        dp=[a_init%K]+[0 for _ in range(K)]
        for i in range(1,K+100):
            dp[i]=(dp[i-1]*10+a_init)%K
            if dp[i]%K==0:
                return (i+1)
        return -1

def main():    
    K = int(input().strip())    
    print(solve(K))
    # print(f(7,K)%K)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from __future__ import print_function

from functools import reduce
from operator import mul
from collections import Counter
from collections import deque
from itertools import accumulate
from queue import Queue
from queue import PriorityQueue as pq
from heapq import heapreplace
from heapq import heapify
from heapq import heappushpop
from heapq import heappop
from heapq import heappush
import heapq
import time
import random
import bisect
import itertools
import collections
from fractions import Fraction
import fractions
import string
import math
import operator
import functools
import copy
import array
import re
import sys
sys.setrecursionlimit(500000)


input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return

# from fractions import gcd
# from math import gcd

# def lcm(n, m):
#     return int(n * m / gcd(n, m))


# def coprimize(p, q):
#     common = gcd(p, q)
#     return (p // common, q // common)


# def find_gcd(list_l):
#     x = reduce(gcd, list_l)
#     return x


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


mod = 1000000007


def combinations_count_mod(n, r):
    r = min(r, n - r)
    numer = reduce(lambda x, y: x*y % mod, range(n, n - r, -1), 1)
    denom = pow(reduce(lambda x, y: x*y % mod, range(1, r + 1), 1), mod-2, mod)
    return numer * denom % mod


def f(a_init, n):
    # n_init=7
    if n == 0:
        return (a_init*10 + a_init)%K
    else:
        return (f(a_init, n-1)*10 + a_init)%K

a_init=7
def solve(K):
    if K%2==0 or K%5==0:
        return -1
    else:
        dp=[a_init%K]+[0 for _ in range(K)]
        for i in range(1,K):
            dp[i]=(dp[i-1]*10+a_init)%K
            if dp[i]%K==0:
                return (i+1)
        return -1

def main():    
    K = int(input().strip())    
    print(solve(K))
    # print(f(7,K)%K)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

else:
    Ans = -1
    a = 7 % K

    for i in range(1, K + 1):
        a = (a * 10 + 7) % K

        if a == 0:
            Ans = i + 1
            break

    print(Ans)

Submission status: Wrong Answer

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

else:
    Ans = -1
    a = 7 % K

    for i in range(1, K + 1):
        a = (a * 10 + 7) % K

        if a == 0:
            Ans = i + 1
            break

    print(Ans)

Submission status: Wrong Answer

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

elif K == 7:
    print(1)

else:
    if (K % 7) == 0:
        K //= 7

    T, R, md, Ans = (1, 1, 0, -1)

    for i in range(1, K + 1):
        md = 10 % K
        R = (R * md) % K
        T = (T + R) % K

        if T == 0:
            Ans = i + 1
            break

    print(Ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
param_k = int(input())
 
#param_k = 999983
    
if param_k % 2 == 0:
  print(-1)
  
elif param_k % 5 == 0:
  print(-1)
  
else:
  n=0
  for i in range(1000000):
    n = 10*n + 7
    print(n)
    if n % param_k == 0:
      print(i+1)
      break
    else:
      n = n % param_k
    #if i == param_k + 10 - 1:
    #  print(-1)
  else:
    print(-1)

Submission status: Wrong Answer

Solution code:
k=int(input())

if k%2==0 or k%5==0:
    print(-1)
else:
    for i in range(k*(10**2)):
        x=i*k
        x2=list(str(x))
        x3=set(x2)
        if x3=={'7'}:
            print(len(x2))
            exit()
    print(-1)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(1000000000)
import math
from math import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations, chain, product
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    # 10**6
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     # 10**6
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    num = 1
    for i in range(n, n-k, -1):
        num = num * i % modp
    den = 1
    for i in range(2, k+1):
        den = den * i % modp
    return num * get_inv(den, modp) % modp

def comb_from_list(n, k, modp, fs, invs):
    return fs[n] * invs[n-k] * invs[k] % modp

#

class UnionFindEx:
    def __init__(self, size):
        #正なら根の番号、負ならグループサイズ
        self.roots = [-1] * size
    def getRootID(self, i):
        r = self.roots[i]
        if r < 0:   #負なら根
            return i
        else:
            r = self.getRootID(r)
            self.roots[i] = r
            return r
    def getGroupSize(self, i):
        return -self.roots[self.getRootID(i)]
    def connect(self, i, j):
        r1, r2 = self.getRootID(i), self.getRootID(j)
        if r1 == r2:
            return False
        if self.getGroupSize(r1) < self.getGroupSize(r2):
            r1, r2 = r2, r1
        self.roots[r1] += self.roots[r2]    #サイズ更新
        self.roots[r2] = r1
        return True

Yes = 'Yes'
No = 'No'



def main():
    K = ii()
    n = 7%K
    s = set()
    for i in range(K+10):
        if n == 0:
            print(i)
            return
        n = (10*n + 7) % K
        if n in s:
            break
        s.add(n)
    print(-1)






main()

Submission status: Wrong Answer

Solution code:
k = int(input())

n = [0]*10000000
t = 7

for i in range(1,7):
    n[t] = 1
    t = t+7*10**i
    
ma = int(10000000/k)
kk = 0
for i in range(1, ma):
    if n[kk] == 1:
        print(sum(n[:kk+1]))
        break
    if i == ma - 1:
        print(-1)
    else:
        pass
    kk += k

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(1000000000)
import math
from math import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations, chain, product
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    # 10**6
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     # 10**6
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    num = 1
    for i in range(n, n-k, -1):
        num = num * i % modp
    den = 1
    for i in range(2, k+1):
        den = den * i % modp
    return num * get_inv(den, modp) % modp

def comb_from_list(n, k, modp, fs, invs):
    return fs[n] * invs[n-k] * invs[k] % modp

#

class UnionFindEx:
    def __init__(self, size):
        #正なら根の番号、負ならグループサイズ
        self.roots = [-1] * size
    def getRootID(self, i):
        r = self.roots[i]
        if r < 0:   #負なら根
            return i
        else:
            r = self.getRootID(r)
            self.roots[i] = r
            return r
    def getGroupSize(self, i):
        return -self.roots[self.getRootID(i)]
    def connect(self, i, j):
        r1, r2 = self.getRootID(i), self.getRootID(j)
        if r1 == r2:
            return False
        if self.getGroupSize(r1) < self.getGroupSize(r2):
            r1, r2 = r2, r1
        self.roots[r1] += self.roots[r2]    #サイズ更新
        self.roots[r2] = r1
        return True

Yes = 'Yes'
No = 'No'



def main():
    K = ii()
    n = K
    s = set()
    for i in range(K):
        if n == 0:
            print(i)
            return
        n = (10*n + 7) % K
        if n in s:
            break
        s.add(n)
    print(-1)






main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
K = int(input())

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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