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())
sevs=7
for x in range(1,k+1):
  if sevs%k==0:
    print(x)
    exit()
  else:
    sev=(10*sevs+7)%k
print('-1')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
k=int(input())
a=int(7)
x=int(1)
n=int(0)
while n>=1:
  if a%k==0:
    print(x)
    n=1
  else:
    a=(a*10)+7
    x=x+1

Submission status: Wrong Answer

Solution code:
k=int(input())
a=7
x=1
n=0
while n>=1:
  if a%k==0:
    print(x)
    n=1
  else:
    a=(a*10)+7
    x=x+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
    #if i == param_k + 10 - 1:
    #  print(-1)
  else:
    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
    if i == param_k + 10 - 1:
      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(param_k + 10):
    n = 10*n + 7
    print(n)
    if n % param_k == 0:
      print(i+1)
      break
    if i == param_k + 10 - 1:
      print(-1)

Submission status: Wrong Answer

Solution code:
param_k = int(input())
 
#param_k = 4
    
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 % 7 == 0:
      print(i+1)
      break
    if i == param_k + 10 - 1:
      print(-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys


a = int(input())

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

n = 7
cur = 0
for i in range(1, 10 ** 7):
	#b = sum([(7 * (10**x)) for x in range(i + 1)])
    cur *= 10
    cur += 7
    cur %= a
    if cur == 0:
        print(i)
        sys.exit()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
 
def I(): return int(input())

def main():
    
    K = I()
    
    if K%2 == 0 or K <= 0:
        print('-1')
        exit()
    
    ans = 1
    n = 7
    for i in range(K):
        
        if n%K ==0:
            print(ans)
            break
        
        n = (10*n + 7)%K  
        ans += 1

main()

Submission status: Wrong Answer

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

    m = 7 % K
    if m == 0:
        print(1)
        return

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

if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
 
def I(): return int(input())

def main():
    
    K = I()
    if K%2 == 0:
        print('-1')
        exit()
    
    ans = 1
    n = 7
    for i in range(K):
        
        if n%K ==0:
            print(ans)
            break
        
        n = (10*n + 7)%K  
        ans += 1

main()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
 
def I(): return int(input())

def main():
    
    K = I()
    if K%2 == 0:
        print('-1')
        sys.exit()
    
    ans = 1
    n = 7
    for i in range(K):
        
        if n%K ==0:
            print(ans)
            break
        
        n = (10*n + 7)%K  
        ans += 1

main()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
 
def I(): return int(input())

def main():
    
    if K%2 == 0:
        print('-1')
        sys.exit()
    
    ans = 1
    n = 7
    for i in range(K):
        
        if n%K ==0:
            print(ans)
            break
        
        n = (10*n + 7)%K  
        ans += 1

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
 
def I(): return int(input())

def main():
    
    if K%2 == 0:
        print('-1')
        sys.exit()
    
    ans = 1
    n = 7
    for i in range(K):
        
        if n%K ==0:
            print(ans)
            break
        
        n = (10*n + 7)%K  
        print(f"ai{i+1}: ",n)
        ans += 1

Submission status: Wrong Answer

Solution code:
K = int(input())
ans = -1

if K % 7 == 0:
  for i in range(K):
    if 10 ** i % (9 * K / 7) == 1:
      ans = i
      break
else:
  for i in range(K):
    if 10 ** i % (9 * K) == 1:
      ans = i
      break
  
print(ans)

Submission status: Wrong Answer

Solution code:
k = int(input())

ans = []
memo = 7 % k
if(7 % k == 0):
    ans.append(0)
for i in range(k):
    memo = (10*memo + 7) % k
    if memo % k == 0:
        ans.append(i)
print(-1 if not len(ans) else ans[0] + 2)

Submission status: Wrong Answer

Solution code:
k = int(input())

ans = []
memo = 7 % k
for i in range(k):
    memo = (10*memo + 7) % k
    if memo % k == 0:
        ans.append(i)
print(-1 if not len(ans) else ans[0] + 2)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def calc_term(k):
    # [i] = 10 ^ i (mod k) 
    power_ten_mod_k = [1] * k
    for i in range(1, k):
        power_ten_mod_k[i] = (10 * power_ten_mod_k[i-1]) % k
    # [i] = 111...11 (1 が i + 1 個) (mod k)
    one_consec_mod_k = power_ten_mod_k[:]
    for i in range(1, k):
        one_consec_mod_k[i] = (one_consec_mod_k[i] + one_consec_mod_k[i-1]) % k
    for i in range(k):
        if one_consec_mod_k[i] == 0:
            return i + 1
    return -1
    


def main():
    k = int(input())
    if k % 7 == 0:
        k //= 7
    print(calc_term(k))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# from collections import defaultdict


# # 試し割り法による素因数分解
# # defaultdictにつっこむやつ
# def prime_factorize_dict(n):
#     dd = defaultdict(int)
#     while n % 2 == 0:
#         dd[2] += 1
#         n //= 2
#     f = 3
#     while f * f <= n:
#         if n % f == 0:
#             dd[f] += 1
#             n //= f
#         else:
#             f += 2
#     if n != 1:
#         dd[n] += 1
#     return dd


k = int(input())
# print(prime_factorize_dict(k))
if k % 2 == 0:
    print(-1)
else:
    count = 1
    if k == 1 or k % 7 == 0:
        print(1)
    else:
        now = 7 % k
        while (1):
            count += 1
            now = ((now * 10 + 7) % k) % k
            if now == 0:
                print(count)
                exit()
            if count >= 1000000:
                print(-1)
                exit()

Submission status: Wrong Answer

Solution code:
k = int(input())

if k % 2 == 0:
    print(-1)
else:
    count= 1
    if k==7:
        print(1)
    else:
        now = 7%k
        while(1):
            count += 1
            now = (now*10) % k + 7 % k
            if now % k == 0:
                print(count)
                exit()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def makedivisor(N):  # 約数列挙
    p, upper, lower = 1, [], []
    while p * p <= N:
        if N % p == 0:
            lower.append(p)
            if p * p != N:
                upper.append(N // p)
        p += 1
    return lower + upper[::-1]


def totient(N):  # オイラーのトーシェント関数
    p, phi = 2, N
    while p * p <= N:
        if N % p == 0:
            phi = phi // p * (p - 1)
        while N % p == 0:
            N //= p
        p += 1
    if N > 1:
        phi = phi // N * (N - 1)
    return phi

k = int(input()) * 9

# 解説AC オイラーの定理 O(n**0.5)
if k % 2 == 0 or k % 5 == 0:
    print(-1)
    exit()
if k % 7 == 0:
    k //= 7

cnt = totient(k)
num = makedivisor(cnt)
print(cnt)
for i in num:
    if pow(10, i, k) == 1:
        print(i)
        break

Submission status: Wrong Answer

Solution code:
def makedivisor(N):  # 約数列挙
    p, upper, lower = 1, [], []
    while p * p <= N:
        if N % p == 0:
            lower.append(p)
            if p * p != N:
                upper.append(N // p)
        p += 1
    return lower + upper[::-1]

def totient(N): # オイラーのトーシェント関数
    p, phi = 2, N
    while p * p <= N:
        if N % p == 0:
            phi = phi // p * (p - 1)
        while N % p == 0:
            N //= p
        p += 1
    return phi

k = int(input()) * 9

# 解説AC オイラーの定理 O(n**0.5)
if k % 2 == 0 or k % 5 == 0:
    print(-1)
    exit()
if k % 7 == 0:
    k //= 7

cnt = totient(k)
num = makedivisor(cnt)
for i in num:
    if pow(10, i, k) == 1:
        print(i)
        break

Submission status: Wrong Answer

Solution code:
def makedivisor(N):  # 約数列挙
    p, upper, lower = 1, [], []
    while p * p <= N:
        if N % p == 0:
            lower.append(p)
            if p * p != N:
                upper.append(N//p)
        p += 1
    return lower + upper[::-1]


k = int(input()) * 9

# 解説AC オイラーの定理 O(n**0.5)
if k % 2 == 0 or k % 5 == 0:
    print(-1)
    exit()
if k % 7 == 0:
    k //= 7

totient = k - len(makedivisor(k)) + 1
num = makedivisor(totient)
ans = k
for i in num:
    if pow(10, i, k) == 1:
        print(i)
        break

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
mo = 10**9+7

def main():
    K = II()
    d = dict()
    value = 7
    ans = 1
    r = 7
    flag = False
    while not r in d:
        if r == 0 :
            flag=True
            break
        else:
            d[r] = True
            r = r*10+7
            r = r % K
            ans += 1
    if flag:
        print(ans)
    else:
        print(-1)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
K = int(input())

out=-1

if K%7==0:
    dammy = K//7
    print(dammy)
    for i in range(1,10**6):
        #if (10**i -1) % 9 ==0:
        if pow(10,i,9*dammy)==1:
             out=i
             break

else:
    for i in range(1,10**6):
        #if (10**i -1) % (9*K)==0:
        if pow(10,i,9*K)==1:
            out=i
            break

print(out)

Submission status: Wrong Answer

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

ans = -1

for i in x:
  if x == 0:
    ans = i + 1
    break

print(i)

Submission status: Wrong Answer

Solution code:
K = int(input())

out=-1

if K==7:
    for i in range(1,10**6):
        #if (10**i -1) % 9 ==0:
        if pow(10,i,9)==1:
             out=i
             break

else:
    for i in range(1,10**6):
        #if (10**i -1) % (9*K)==0:
        if pow(10,i,9*K)==1:
            out=i
            break

print(out)

Submission status: Wrong Answer

Solution code:
K = int(input())

out=-1

if K==7:
    for i in range(1,10**6):
        #if (10**i -1) % 9 ==0:
        if pow(10,i,9)==1:
             out=i
             break

else:
    for i in range(1,10**6):
        #if (10**i -1) % (9*K)==0:
        if pow(10,i,9*K)==1:
            out=i
            break

print(i)

Submission status: Wrong Answer

Solution code:
k=int(input())
ans=-1
s="7"
cnt=1
if k%2!=0 and k%5!=0:
  if k%3!=0:
    ans=k-1
  else:
    while int(s)%k!=0:
      s+="7"
      cnt+=1
    ans=cnt
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())

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

n7 = 0
 
for i in range(6):
  n7 += 7*(10**(i))
  if n7 % N == 0:
    print(i+1)
    exit()

print(-1)

Submission status: Wrong Answer

Solution code:
N = int(input())

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

Submission status: Wrong Answer

Solution code:
N = int(input())

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())

n7 = 0

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())

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

Submission status: Wrong Answer

Solution code:
N = int(input())

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

Submission status: Wrong Answer

Solution code:
N = int(input())

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

Submission status: Wrong Answer

Solution code:
N = int(input())

n7 = 0

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
K = int(input())

N = 0

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

Submission status: Wrong Answer

Solution code:
K = int(input())

N = 0

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

Submission status: Wrong Answer

Solution code:
K = int(input())

N = 0

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

Submission status: Wrong Answer

Solution code:
K = int(input())

N = 0

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

Submission status: Wrong Answer

Solution code:
K = int(input())

N = 0

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

Submission status: Wrong Answer

Solution code:
K = int(input())

r = 0
while True:
    N = 0
    for i in range(r):
        N += 7*(10**i)
    if N%K ==0:
        break
    r += 1

print(r)

Submission status: Wrong Answer

Solution code:
def function(K):
    current_rem = 7
    for j in range(K):
        current_rem = (10*current_rem+7) % K
        if current_rem % K == 0:
            return j+2
    return -1

print(function(int(input())))

Submission status: Wrong Answer

Solution code:
k = int(input())
i = 1
a = 7
a = a % k
while a != 0:
  i += 1
  a = (10*a + 7) % k
  if i == 10**5:
    i = -1
    break

print(i)

Submission status: Wrong Answer

Solution code:
k = int(input())
i = 1
a = 7
a = a % k
while a != 0:
  i += 1
  a = (10*a + 7) % k
  if i == 10**3:
    i = -1
    break

print(i)

Submission status: Wrong Answer

Solution code:
k = int(input())
i = 1
a = 7
while a != 0:
  i += 1
  a = (10*a + 7) % k
  if i == 10**9+7:
    i = -1
    break

print(i)

Submission status: Wrong Answer

Solution code:
k = int(input())
i = 1
a = 7
remainder = a % k
while a != 0:
  i += 1
  a = (10*a + 7) % k
  if i == 10**9+7:
    i = -1
    break

print(str(i))

Submission status: Wrong Answer

Solution code:
k = int(input())
i = 1
a = 7
remainder = a % k
while a != 0:
  i += 1
  a = (10*a + 7) % k
  if i == 10**9+7:
    i = -1
    break

print(i)

Submission status: Wrong Answer

Solution code:
def main():
  k = int(input())
  for i in range(2, k):
    if int('7' * i) % k == 0:
      print(i)
      return
  else:
    print(-1)

if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
K = int(input())
s=[]
x=7%K
for i in range(K):
    if x==0 or s.count(x)!=0:
        print(i+1)
        break
    s.append(x)
    x=(x*10+7)%K
else:
    print('-1')

Submission status: Wrong Answer

Solution code:
#{S}= 7,77,777,7777,...
#(1)S_5=77777とすると、10*S_5-S_5=700000-7
#S=(10^5*-1)*7/9
#(2)漸化式考える
#a(n)=10*a(n-1)+7 あとはmodで考える。mod K =0になればよい。
#p(n-1)=a(n-1) mod K とp(n)=a(n) mod Kの関係も、p(n)=(p(n-1)*10+7) mod K ->p(n)はどこかで繰り返す。
# ->一回現れた数字がもう一度現れた時点でbreak 
#or 0<=p(n)<K  たかだかKしかないので、K回繰り返せば十分
#
K = int(input())
# seven = ''
# dum = True
# count = 0
# i = 1
# d = []
# if(K % 2 == 0):
#     print('-1')
# else:
#     for i in range(10): 
#         d.append(int(str(seven)+'7'))
#         i+=1
# print('finish')

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

k = int(input())
s = 7 % k
for i in range(1, k):
	if not s:
		exit(print(i))
	s = (s + 7 * pow(10, i, k)) % k
print(-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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(i)
        break
print('-1')

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

Submission status: Wrong Answer

Solution code:
def main():
  s = input()
  k = int(s)
  if k % 2 == 0:
    print("-1")
    exit(0)
  kurai = 1
  count = 1
  sevens = 0
  while True:
    sevens = sevens + 7 * kurai
    if sevens % k == 0:
      print(str(count))
      break
    else:
      count+=1
      kurai = kurai * 10
    print(str(count))

if __name__ == "__main__":
  main()

Submission status: Wrong Answer

Solution code:
k = int(input())
s = 7

i = 1
res = 0
while s < 1000000:
  if s % k == 0:
    res = i
    break
  i += 1
  s = s * 10 + 7

if res:
  print(res)
else:
  print(-1)

Submission status: Wrong Answer

Solution code:
ma = lambda :map(int,input().split())
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
import collections
import math
import itertools
import heapq as hq
k = ni()

if k%2==0 or k%5==0:
    print(-1)
if k%7==0:
    L=9*k//7
else:
    L=9*k
tmp=1
for i in range(1,10**6):
    tmp = tmp*10 %L
    if tmp==1:
        print(i)
        break
else:
    print(-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
K=int(input())
if K%2 == 0 or K%5 == 0:
  print(-1)
else:
  base = ''
  count = 1
  while(1):
    base += '7'
    if int(base)%K == 0:
      print(count)
      break
    else:
      count += 1
    if count >= K:
      print(-1)
      break

Submission status: Wrong Answer

Solution code:
K=int(input())
if K%2 == 0 or K%5 == 0:
  print(-1)
else:
  base = ''
  while(1):
    base += '7'
    if int(base)%K == 0:
      print(base)
      break

Submission status: Wrong Answer

Solution code:
K=int(input())
i=1
if K%2==0 or K%5==0:
  print(-1)
else:
  L=9*K
  b=10
  while True:
    b=b%L
    if b==1:
      print(i)
      break
    b=b*10
    i+=1

Submission status: Wrong Answer

Solution code:
K = int(input())
nana = 7
for i in range(1000000):
    if nana % K == 0:
        print(i + 1)
        exit()
    nana *= 10
    nana += 7
    nana %= K

Submission status: Wrong Answer

Solution code:
k=int(input())


if(k%2==0):
	print(-1)
else:
    n=len(str(k))
    s=""
    for i in range(n):
        s+="7"
    p=int(s)

    if(p<k):
        p=p*10+7
    ct=n		
    #print(p)
    while(p%k!=0):
        ct+=1
        p=p*10+7
        #print(p)
    print(ct)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
K = int(input())

if 7%K==0:
  print("1")
  exit(0)
if 77%K==0:
  print("2")
  exit(0)
if 777%K==0:
  print("3")
  exit(0)
if 7777%K==0:
  print("4")
  exit(0)
if 77777%K==0:
  print("5")
  exit(0)
if 777777%K==0:
  print("6")
  exit(0)
if 7777777%K==0:
  print("7")
  exit(0)
  
print("-1")

Submission status: Wrong Answer

Solution code:
K = int(input().rstrip())
n = 1
if K%7==0:
    L = 9 * K / 7
else:
    L = 9 * K
R = 10 ** n
s = set()
if K ==7:
    print(1)
else:
    while R!=1:
        R = (10 * R) % L
        n += 1
        if R in s:
            print(-1)
            break
        else:
            s.add(R)
    else:
        print(n)

Submission status: Wrong Answer

Solution code:
K = int(input().rstrip())
n = 1
if K%7==0:
    L = 9 * K / 7
else:
    L = 9 * K
R = 10 ** n
s = set()
while R!=1:
    R = (10 * R) % L
    n += 1
    if R in s:
        print(-1)
        break
    else:
        s.add(R)
else:
    print(n)

Submission status: Wrong Answer

Solution code:
K = int(input())
x = 7
count = 1
if K % 2 ==0:
  print("-1")
  exit(0)
for i in range(10000):
  if x % K == 0:
    print(count)
    exit(0)
  else:
    x = 10*x + 7
    count += 1
print("-1")

Submission status: Wrong Answer

Solution code:
K = int(input().rstrip())
n = len(str(K))
if K%7==0:
    L = 9 * K / 7
else:
    L = 9 * K
R = 10 ** n
s = set()
while R!=1:
    R = (10 * R) % L
    n += 1
    if R in s:
        print(-1)
        break
    else:
        s.add(R)
else:
    print(n)

Submission status: Wrong Answer

Solution code:
K = int(input())
x = 7
count = 0
if K % 2 ==0:
  print("-1")
  exit(0)
for i in range(10**5):
  if x % K == 0:
    print(count)
    exit(0)
  else:
    x = 10*x + 7
    count += 1

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
K = int(input())

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

Submission status: Wrong Answer

Solution code:
K = int(input())

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
X = int(input())

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

Submission status: Wrong Answer

Solution code:
X = int(input())

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

Submission status: Wrong Answer

Solution code:
k = int(input())
power = 0
cnt = 1
if k == 1 or k == 7:
  print(1)
elif k%2 == 0 or k%5 == 0:
  print(-1)
elif k%7 == 0:
  l = k/7
  a = 1
  while(True):
    a = (10*a)%l
    if a == 1:
      break
    cnt+= 1
  print(cnt)
else:
  a = 1
  l = 9*k
  while(True):
    a = (10*a)%l
    if a == 1:
      break
    cnt+=1
  print(cnt)

Submission status: Wrong Answer

Solution code:
k = int(input())
if k % 2 == 0 or k % 5 == 0:
  print(-1)
else:
  if k == 7 or k == 1:
    print(1)
  else:
    if k % 7 == 0:
      k //= 7
    state = 10
    state %= k
    cnt = 1
    while True:
      if state == 1:
        print(cnt)
        break
      state *= 10
      state %= k
      cnt += 1

Submission status: Wrong Answer

Solution code:
k = int(input())
sieve = [True] * 10**6
for i in range(2, 10**6):
  if i <= 10**3 and sieve[i]:
    for j in range(i*i, 10**6, i):
      sieve[j] = False

if k % 2 == 0 or k % 5 == 0:
  print(-1)
else:
  if k == 7 or k == 1:
    print(1)
  else:
    if k % 7 == 0:
      k //= 7
    if sieve[k]:
      print(k-1)
    else:
      state = 10
      cnt = 1
      while True:
        if state % k == 1:
          print(cnt)
          break
        state *= 10
        cnt += 1

Submission status: Wrong Answer

Solution code:
K = int(input())

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

Submission status: Wrong Answer

Solution code:
def main():
    K = int(input())
    a = 7 % K
    d = 1
    for k in range(1, K):
        if a == 0:
            return print(k)
        d *= 10
        d %= K
        a += 7 * d
        a %= K
    print(-1)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
K = int(input())

i = 1

if(K % 2 == 0):
  print(-1)
else:
  while(True):
    num = 0
    for j in range(i):
      num += 7*(10**j)
    if(num % K):
      print(i)
      break
    i += 1

Submission status: Wrong Answer

Solution code:
K = int(input())

i = 0

if(K % 2 == 0):
  print(-1)
else:
  while(True):
    num = 0
    for j in range(i):
      num += 7*(10**j)
    if(num % K):
      print(i+1)
      break
    i += 1

Submission status: Wrong Answer

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