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

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

elif K%7 ==0:
    x = -1
    b = 9*K/7
    c = 10%b

    for i in range(1,K+1):
        if c ==1:
            x = i
            break
        c = (c*10)%b

    print(x)

else:
    x = -1
    b = 9*K
    c = 10%b
    for i in range(1,K+1):
        if c ==1:
            x = i
            break
        #c = (c*10)%b
        print(c)
    print(x)

Submission status: Wrong Answer

Solution code:
import sys
K = int(input())
N = 0
for i in range (K):
    if((K // (N + (10**i)*7)) == 0):
        print(i + 1)
        sys.exit()
    else:
        N = (N + (10**i)*7)
print(-1)

Submission status: Wrong Answer

Solution code:
K = int(input())

if K%2 == 0:
    print(-1)
else:
    x = -1
    for i in range(1,K):
        a = (10**i -1)*7
        b = 9*K
        if a%b == 0:
            x = i
            break

    print(x)

Submission status: Wrong Answer

Solution code:

k=int(input())

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

a=[]
judge=0
a.append("")
a.append(7%k)
for i in range(2,k):
    a.append((a[i-1]*10+7)%k)
for i in range(1,k):
    if a[i]==0:
        print(i)
        judge=1
        break
if judge==0:
    print(-1)

Submission status: Wrong Answer

Solution code:
K = int(input())

if K%2 == 0 or K%5==0:
    print(-1)
else:
    x = -1
    for i in range(1,K):
        a = (10**i -1)*7
        b = 9*K
        if a%b == 0:
            x = i
            break

    print(x)

Submission status: Wrong Answer

Solution code:

k=int(input())
a=[]
judge=0
a.append("")
a.append(7%k)
for i in range(2,k):
    a.append((a[i-1]*10+7)%k)
for i in range(1,k):
    if a[i]==0:
        print(i)
        judge=1
        break
if judge==0:
    print(-1)

Submission status: Wrong Answer

Solution code:
#a問題
# x=int(input())
#
# if x>=30:
#     print("Yes")
# else:
#     print("No")

#b問題
# n,d = (int(y) for y in input().split())
# x=[]
# count=0
# for i in range(n):
#     n, m = (int(y) for y in input().split())
#     s=n**2+m**2
#     # print(s)
#     if s<=(d**2):
#         count+=1
# print(count)

#------------------------------------------------------------------------------------------------
#c問題
k=int(input())
a=[]
judge=0
a.append("")
a.append(7%k)
for i in range(2,k):
    a.append((a[i-1]*10+7)%k)
for i in range(1,k):
    if a[i]==0:
        print(i)
        judge=1
        break
if judge==0:
    print(-1)

Submission status: Wrong Answer

Solution code:
#a問題
# x=int(input())
#
# if x>=30:
#     print("Yes")
# else:
#     print("No")

#b問題
# n,d = (int(y) for y in input().split())
# x=[]
# count=0
# for i in range(n):
#     n, m = (int(y) for y in input().split())
#     s=n**2+m**2
#     # print(s)
#     if s<=(d**2):
#         count+=1
# print(count)

#------------------------------------------------------------------------------------------------
#c問題
k=int(input())
a=[]
judge=0
a.append("")
a.append(7%k)
for i in range(2,k):
    a.append((a[i-1]*10+7)%k)
for i in range(k):
    if a[i]==0:
        print(i)
        judge=1
        break
if judge==0:
    print(-1)

Submission status: Wrong Answer

Solution code:
#c問題
k=int(input())
a=[]
judge=0
a.append(7%k)
for i in range(1,k):
    a.append((a[i-1]*10+7)%k)
for i in range(k):
    if a[i]==0:
        print(i)
        judge=1
        break
if judge==0:
    print(-1)

Submission status: Wrong Answer

Solution code:
import sys, os, math, bisect, itertools, collections, heapq, queue, copy, array

# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
# from decimal import Decimal
# from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
INF = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    K = ii()

    ret = []
    for i in range(K + 1):
        if i == 0:
            ret.append(7 % K)
        else:
            ret.append(ret[i - 1] * 10 + 7)
    for i in range(K + 1):
        if ret[i] == 0:
            print(i + 1)
            exit()
    else:
        print(-1)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys, os, math, bisect, itertools, collections, heapq, queue, copy, array

# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
# from decimal import Decimal
# from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
INF = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    K = ii()

    ret = [7]
    for i in range(1, K + 1):
        ret.append((ret[i - 1] * 10 + 7) % K)
        
    for i in range(K + 1):
        if ret[i] == 0:
            print(i + 1)
            exit()
    else:
        print(-1)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys, os, math, bisect, itertools, collections, heapq, queue, copy, array

# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
# from decimal import Decimal
# from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
INF = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    K = ii()
    if K % 2 == 0:
        print(-1)
        exit()
    ret = [7]
    for i in range(1, K):
        ret.append((ret[i - 1] * 10 + 7) % K)
    for i in range(K):
        if ret[i] == 0:
            print(i + 1)
            exit()


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys, os, math, bisect, itertools, collections, heapq, queue, copy, array

# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
# from decimal import Decimal
# from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
INF = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    K = ii()
    ret = [7]
    for i in range(1, K):
        ret.append((ret[i - 1] * 10 + 7) % K)
    for i in range(K):
        if ret[i] == 0:
            print(i + 1)
            exit()


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
import re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []


def main():
    K=i_input()
    a = []
    
    for i in range(0,K-1):
        if(i==0):
            a.append(7 % K)
        else:
            a.append((a[i-1]*10+7)%K)
    
    for i in range(0,len(a),1):
        if(a[i] == 0):
            print(i+1)
            return

    print(-1)
    return
        
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
import re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []


def main():
    K=i_input()
    a = []
    
    for i in range(0,K-1):
        if(i==0):
            a.append(7 % K)
        else:
            a.append((a[i-1]*10+7)%K)
    
    for i in range(0,len(a),1):
        if(a[i] == 0):
            print(i+1)
            return

    print("-1")
        
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
K = int(input())
 
i, a = 0, 0
l = []
for i in range(K-1):
  a = (10*a + 7) % K
  l.append(a)

j, ans = 0, -1
for j in range(K-1):
  if l[j] == 0:
    ans = j + 1
    break
    
print(ans)

Submission status: Wrong Answer

Solution code:
K = int(input())
 
i, a = 0, 0
l = []
for i in range(K):
  a = (10*a + 7) % K
  print(a)
  l.append(a)
  
j, ans = 0, 0
for j in range(K):
  if l[j] == 0:
    ans = j
    break
  else: 
    ans = -1

print(ans)

Submission status: Wrong Answer

Solution code:
K = int(input())

i, a = 0, 0
l = []
for i in range(K):
  a = 10*a + 7
  l.append(a % K)
  
j, ans = 0, 0
for j in range(K):
  if l[j] == 0:
    ans = j
    break
  else: 
    ans = -1

print(ans)

Submission status: Wrong Answer

Solution code:
k = int(input())
a = [7 % k]
for i in range(1,k):
    tmp = (a[-1] * 10 +7) % k
    if tmp == 0:
        print(i+1)
        exit()
    else:
        a.append(tmp)
print('-1')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
k = int(input())
d1 = k % 10
mae = 0
sd = [0]*10
cnt = 0
if not d1 in (1, 3, 7, 9):
  print(-1)
  exit()
for i in range(1,10) :
  sd[d1 * i % 10] = i
print(sd)

d2 = 7 - mae % 10
s = str(sd[d2] * k)
for j in range(9):
  print("s1=",s)
  for i in range(len(s)-1, -1, -1):
    print("s[",i,"]=",s[i])
    if (s[i]) == "7":
      cnt += 1
    else:
      s = s[0:i+1]
#      mae = int(s)
      print("s2=",s)
#      d2 = 7 - mae % 10
#      s = str(sd[d2] * k)
      break
print("cnt=",cnt)

Submission status: Wrong Answer

Solution code:
K = int(input())

n = 0
for i in range(1,K+1):
    n = (n*10 + 7)%K
    if n == 0:
        print("%d",i)
        break

else:
    print(-1)

Submission status: Wrong Answer

Solution code:
k = int(input())

sevens = [0] * k

sevens[0] = 7 % k

if k == 7:
    print(1)
else:
    for i in range(1, k):
        new = (sevens[i - 1] * 10 + 7) % k
        sevens[i] = new

        if new == 0:
            print(i + 1)
            break
    else:
        print(-1)

Submission status: Wrong Answer

Solution code:
k = int(input())

sevens = [0] * k

sevens[0] = 7 % k

for i in range(1, k):
    new = (sevens[i - 1] * 10 + 7) % k
    sevens[i] = new
    
    if new == 0:
        print(i + 1)
        break
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
K = int(input())
firsta = 7 % K
if firsta == 0:
    print(1)
elif firsta == 77 % K:
    print(-1)
else:
    ans = 2
    preva = 77 % K
    while preva != firsta and preva != 0:
        preva = ((preva*10)+7) % K
        ans += 1
    print(ans)

Submission status: Wrong Answer

Solution code:
K = int(input())
K2 = len(str(K))
ans = K2
prev7 = 7
for i in range(1,K2):
    prev7 = 10* prev7 + 7
firsta = prev7%K
preva = ((firsta*10)+7) % K
if preva == firsta:
    ans = -2
while preva != firsta and preva != 0:
    preva = ((preva*10)+7) % K
    ans += 1
    if preva == firsta:
        ans = -2
print(ans+1)

Submission status: Wrong Answer

Solution code:
k = int(input())
s = 7
num = 1
if k == 2:
    print(-1)
else:
    while 1:
        s %= k
        if s == 0:
            print(num)
            break
        print(num, s)
        num += 1
        s *= 10
        s += 7

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

s=[]
s.append(7%k)
for i in range(1,k):
    s.append((s[i-1]*10+7)%k)
    if s[i]==0:
        print(i+1)
        exit()
print(-1)

Submission status: Wrong Answer

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

s=[]
s.append(7)
for i in range(1,k):
    s.append((s[i-1]*10+7)%k)
    if s[i]%k==0:
        print(i+1)
        exit()
    else:
        i+=1
print(-1)

Submission status: Wrong Answer

Solution code:
K = int(input())

first_mod = 7 % K
"""
cnt = 1
if first_mod == 0:
    print(1)
else:
    flg = True
    for i in range(2,K):
        seven = old * 10 + 7
        mod = seven % K
        cnt += 1
        old = seven
        if mod == 0:
            break
        if mod == first_mod:
            flg = False
            break
    if flg:
        print(cnt)
    else:
        print(-1)
"""
old_mod = now_mod = first_mod

cnt = 1
if first_mod == 0:
    print(1)
else:
    flg = False
    for i in range(2,K):
        now_mod = ((old_mod * 10) + 7) % K
        cnt += 1
        old_mod = now_mod
        if now_mod == 0:
            flg = True
            break
        if now_mod == first_mod:
            break
    if flg:
        print(cnt)
    else:
        print(-1)

Submission status: Wrong Answer

Solution code:
K = int(input())

first_mod = 7 % K
"""
cnt = 1
if first_mod == 0:
    print(1)
else:
    flg = True
    for i in range(2,K):
        seven = old * 10 + 7
        mod = seven % K
        cnt += 1
        old = seven
        if mod == 0:
            break
        if mod == first_mod:
            flg = False
            break
    if flg:
        print(cnt)
    else:
        print(-1)
"""
old_mod = now_mod = first_mod

cnt = 1
if first_mod == 0:
    print(1)
else:
    flg = True
    for i in range(2,K):
        now_mod = ((old_mod * 10) + 7) % K
        cnt += 1
        old_mod = now_mod
        if now_mod == 0:
            break
        if now_mod == first_mod:
            flg = False
            break
    if flg:
        print(cnt)
    else:
        print(-1)

Submission status: Wrong Answer

Solution code:
k = int(input())
if k % 2 == 0:
    print(-1)
else:
    mod = 7 % k
    counter = 1
    memo = 1
    mod_map = set()
    mod_map.add(mod)
    while mod != 0:
        memo = ((memo % k) * (10 % k)) % k
        mod = (mod + 7 * memo) % k
        if mod not in mod_map:
            mod_map.add(mod)
        else:
            print(-1)
            break
        counter += 1
        if mod == 0:
            break
    print(counter)

Submission status: Wrong Answer

Solution code:
k = int(input())
if k % 2 == 0:
    print(-1)
else:
    mod = 7 % k
    counter = 1
    memo = 1
    while True:
        memo = ((memo % k) * (10 % k)) % k
        mod = (mod + 7 * memo) % k
        counter += 1
        if mod == 0:
            print(counter)
            break

Submission status: Wrong Answer

Solution code:
n = int(input())
k = 0
c = 1
q = 100
while q>0:
    k = k*10 + 7
    if k%n==0:
        print(c)
        break
    else:
        c+=1
    q -= 1
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
n = int(input())
k = 0
c = 1
q = 20
while q>0:
    k = k*10 + 7
    if k%n==0:
        print(c)
        break
    else:
        c+=1
    q -= 1
else:
    print(-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
k = 0
c = 1
while True:
    k = k*10 + 7
    if k%n==0:
        print(c)
        break
    elif k/n >0:
        print(-1)
        break
    else:
        c+=1

Submission status: Wrong Answer

Solution code:
K = int(input())
a = [0] * 1000000
a[1] = 7%K

for i in range(2,K):
    #print(a[i-1]*10+7)
    a[i] = (a[i-1]*10+7) % K
    #print(a[i])
for i in range(1,K):
    if a[i] == 0:
        print(i)
        exit()
print("-1")

Submission status: Wrong Answer

Solution code:
K = int(input())
a = [0] * 1000000
a[1] = 7%K

for i in range(2,K):
    #print(a[i-1]*10+7)
    a[i] = (a[i-1]*10+7) % K
    #print(a[i])
    if a[i] == 0:
        #print(a)
        #print()
        print(i)
        exit()
print("-1")

Submission status: Wrong Answer

Solution code:
def last2digit(a):
    sevens = True
    i = 0
    while i < 2 and a > 0:
        if a % 10 != 7:
            sevens = False
        a //= 10
        i += 1
    return sevens

def isPossible(k):
    possible = True
    for i in range(20):
        a = k * i
        if not last2digit(a):
            possible = False
    return (possible)

k = int(input())
k = 101
possible = isPossible(k)


if k % 2 == 0 or possible:
    print(-1)
else:
    ans = 1
    seven = 7
    while seven % k != 0:
        seven = int(str(seven) + '7')
        ans += 1
    print(ans)

Submission status: Wrong Answer

Solution code:
# coding: utf-8


def solve(*args: str) -> str:
    k = int(args[0])

    ret = 1
    a = 7 % k
    while(a):
        a = (a*10+7) % k
        ret += 1
        if k <= ret:
            ret = -1
            break

    return str(ret)


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))

Submission status: Wrong Answer

Solution code:
k=int(input())
s=7
i=1
while s%k!=0:
  i+=1
  s=10*(s%k)+7
  if i==k+1:
    break
else:
  print(i)
  exit()
print(-1)
print(777//3)

Submission status: Wrong Answer

Solution code:
k=int(input())
s=7
i=1
while s%k!=0:
  i+=1
  s=10*(s%k)+7
  if i==k:
    break
else:
  print(i)
  exit()
print(-1)

Submission status: Wrong Answer

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

x = 7%K

for i in range(0,K):
    if x== 0:
        print(count)
        break

    count+=1
    x = (x*10+7)%K

if i== K-1:  
    print(-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#https://atcoder.jp/contests/abc174/tasks/abc174_c
K= int(input(" "))
#B= 7
i= 1

if K%2==0 or K%5==0:
    print(-1)
elif K==1 or K==7:
    print(1)
else:
    while 1:
        i = i + 1
        C= 10**i-1
        #B = 10 * B + 7

        if C%(9*K)==0:
            print(i)
            break

Submission status: Wrong Answer

Solution code:
p = int(input())

if 7 % p == 0:
  print('1')
elif 77 % p == 0:
  print('2')
elif 777 % p == 0:
  print('3')
elif 7777 % p == 0:
  print('4')
elif 77777 % p == 0:
  print('5')
elif 777777 % p == 0:
  print('6')
else:
  print('-1')

Submission status: Wrong Answer

Solution code:
k = int(input())
if(k % 2 == 0 or k % 5 == 0):
  print(-1)
else:
  if(7 % k == 0):
    print(1)
  else:
    a = 1
    amari = 7 % k
    while(a < k):
      a += 1
      amari = (amari*10 + 7) % k
      if(amari == 0):
        print(a)
        break
    if(a == k):
      print(-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
k=int(input())
c=0
x=7
s=-1
for c in range(6):
  if k==7:
      print(1)
      break
  x=x*10+7
  if x%k==0:
      s=c+1
      break
print(s)

Submission status: Wrong Answer

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

x = 7
for ans in range(1, K):

    if  x%K == 0:
        print(ans)
        sys.exit()

    x = (x*10 + 7) % K
print(-1)

Submission status: Wrong Answer

Solution code:
k=int(input())
c=0
x=0
for c in range(6):
  x=x+7*10**c
  if k%2==0 or k%5==0:
    print(-1)
    break
  elif x%k==0:
    print(c+1)
    break

Submission status: Wrong Answer

Solution code:
k=int(input())
c=0
x=0
for c in range(6):
  x=x+7*10**c
  if x%k==0:
    print(c+1)
    break
  elif c==5:
    print(-1)
    break

Submission status: Wrong Answer

Solution code:
k=int(input())
c=0
x=0
for c in range(7):
  x=x+7*10**c
  if x%k==0:
    print(c+1)
    break
  elif c==6:
    print(-1)
    break

Submission status: Wrong Answer

Solution code:
k=int(input())
c=0
x=0
for c in range(6):
  x=x+7*10**c
  if c==7:
    print(-1)
    break
  elif x%k==0:
    print(c+1)
    break

Submission status: Wrong Answer

Solution code:
k=int(input())
c=0
x=0
for c in range(6):
  x=x+7*10**c
  if x%k==0:
    print(c+1)
    break
  if c==5:
    print(-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

K=int(input())
a_i=7%K
i=1
while True:
	i+=1
	a_i=(10*a_i+7)%K
	if a_i==0:
		print(i)
		exit()
	if i>K:
		exit(print(-1))
	
"""
if K % 2 == 0 or K % 5 == 0:
    print(-1)
    exit()


i=1

while True:
	if 7*int("1"*i)%K==0:
		exit(print(i))
	i+=1
	if i>1e+15:
		exit(print(-1))
"""

Submission status: Wrong Answer

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

for ans in range(1, K):
    x = 7*((pow(10, ans, K) - 1)/9)
    if  x%K == 0:
        print(ans)
        sys.exit()

print(-1)

Submission status: Wrong Answer

Solution code:
str = input()
num = int(str)
if num % 2 == 0:
  print('-1');
else:
  i = 1
  j = 7
  while j % num != 0 and i < num:
    j = (j % num) * 10 + 7
    i += 1
  if i == num:
    print('-1');
  else:
    print(i);

Submission status: Wrong Answer

Solution code:
str = input()
num = int(str)
if num % 2 == 0:
  print('-1');
else:
  i = 1
  j = 7
  while j % num != 0 and i < 100:
    j = (j % num) * 10 + 7
    i += 1
  if i == 100:
    print('-1');
  else:
    print(i);

Submission status: Wrong Answer

Solution code:
from functools import lru_cache

K = int(input())
flg = -1

@lru_cache(maxsize = None)
def recur(n):
    if n == 1:
        return 7
    else:
        return (recur(n-1) * 10 + 7) % K
    
a = [recur(n) for n in range(1, K + 1)]

for i in range(0, K):
    if a[i] == 0:
        print(i + 1)
        flg = 0
        break

if flg == -1:
    print(flg)
    
recur.cache_clear()

Submission status: Wrong Answer

Solution code:
from functools import lru_cache

K = int(input())
flg = -1

@lru_cache(maxsize = None)
def recur(n):
    if n == 1:
        return 7
    else:
        return (recur(n-1) * 10 + 7) % K
    
a = [recur(n) for n in range(1, K)]

for i in range(0, K-1):
    if a[i] == 0:
        print(i + 1)
        flg = 0
        break

if flg == -1:
    print(flg)
    
recur.cache_clear()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
k = int(input())

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

print(-1)

Submission status: Wrong Answer

Solution code:
import math

K = int(input())
seven_number = 0
ality = 0
while True:
    ality += 1
    seven_number = seven_number*10+7
    target_number = math.gcd(K,seven_number)
    if ality > K:
        print("-1")
        break
    elif target_number == 1:
        continue
    else:
        print(ality)
        break

Submission status: Wrong Answer

Solution code:
import math
import time

K = int(input())
start_time = time.time()
seven_number = 0
while True:
    elapsed_time = time.time() - start_time
    seven_number = seven_number*10+7
    target_number = math.gcd(K,seven_number)
    if elapsed_time > 10:
        print("-1")
        break
    elif target_number == 1:
        continue
    else:
        print(len(str(seven_number)))
        break

Submission status: Wrong Answer

Solution code:
import math
import time

K = int(input())
start_time = time.time()
seven_number = 0
while True:
    elapsed_time = time.time() - start_time
    seven_number = seven_number*10+7
    target_number = math.gcd(K,seven_number)
    if elapsed_time > 1:
        print("-1")
        break
    elif target_number == 1:
        continue
    else:
        print(len(str(seven_number)))
        break

Submission status: Wrong Answer

Solution code:
import math
import time

K = int(input())
start_time = time.time()
seven_number = 0
while True:
    elapsed_time = time.time() - start_time
    seven_number = seven_number*10+7
    target_number = math.gcd(K,seven_number)
    if elapsed_time > 0.1:
        print("-1")
        break
    elif target_number == 1:
        continue
    else:
        print(len(str(seven_number)))
        break

Submission status: Wrong Answer

Solution code:
import sys

k = int(input())

a =7%k
if a == 0:
    print(1)

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

Submission status: Wrong Answer

Solution code:
import sys

k = int(input())

a =7%k    

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
K = int(input())

iter = 1 # 数列の桁数
ans = -1
seven = 7 # 数列の項

while iter < K:
    if seven >= K:
        if seven % K == 0:
            ans = iter
            break
                
    seven += 7 * 10 ** iter
    iter += 1

print(ans)

Submission status: Wrong Answer

Solution code:
K=int(input())
amari_list = []
amari = 7%K
if amari == 0:
    print(1)
    
amari_list.append(amari)
for i in range(1,K):
    amari = (amari * 10 + 7)% K
    if amari == 0:
        print(i+1)
        break
    if amari in amari_list:
        print(-1)
        break
    if i == (K-1):
        print(-1)
    else:
        #amari_list.append(amari)
        pass