TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: 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.

Submission attempts (in order):

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
k = int(input())
# if  k%2==0 or k%5==0:
#     print(-1)
# else:

#     k_ = k
#     if not 7 in se:
#         k_ = k*7

#     K = int(str(k_)[-1])

#     if K==1:
#         # print("a")
#         x = 7
#     elif K==3:
#         x=9
#     elif K==7:
#         x = 1
#     elif K==9:
#         x = 3

#     # print(x)
#     while True:


#         # print(q)
#         if str(q)=="7"*len(str(q)):
#             print(len(str(q)))
#             break


#         #     break

sen = []
for i in range(1,k*3):
    s =int("7"*i)
    sen += prime_factorize(s)
sen = set(sen)

z = prime_factorize(k)
m = True
for i in z:
    if i in sen:
        m = False
if  k%2==0 or k%5==0:
    print(-1)
elif m:
    print(k-1)
else:
    w = len(str(k))
    
    while True:
        s = "7"*w
        if int(s)%k==0:
            print(w)
            break
        w+=1

k = int(input())
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
if  k%2==0:
    print(-1)
elif len(prime_factorize(k))==1:
    print(k-1)
else:
    w = 1
    
    while True:
        s = "7"*w
        if int(s)%k==0:
            print(w)
            break
        w+=1


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
k = int(input())
if  k%2==0 or k%5==0:
    print(-1)
else:
    se = prime_factorize(k)
    k_ = k
    if not 7 in se:
        k_ = k*7

    K = int(str(k_)[-1])
    
    if K==1:
        # print("a")
        x = 7
    elif K==3:
        x=9
    elif K==7:
        x = 1
    elif K==9:
        x = 3
    z = 0
    # print(x)
    while True:
        s = 10*z + x
        q = k_ * s
        print(q)
        if str(q)=="7"*len(str(q)):
            print(len(str(q)))
            break
        z+=1

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

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

k = int(input())
c = 0
if k%2 ==0 or k%5==0:
    print(-1)
    c=1
elif k==1:
    print(1)
    c=1
if c==0:
    t = 7

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

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
K = int(input())

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

K = int(input())

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

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
k = int(input())
s = 7
c = 0
while True:
  if s == 0:
    break
  s = (10 * s + 7) % k
  c += 1
print(c)

import sys
k = int(input())
if k % 2 == 0 or k % 5 == 0:
  print('-1')
  sys.exit()
s = 7
c = 1
while True:
  if s % k == 0:
    break
  s = (10 * s + 7) % k
  c += 1
print(c)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
n = int(input())
x = 0
for i in range(1, n):
  x = ((10 * x) + 7)%n
  if x == 0:
    print(i)
    return
  
print(-1)
  

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

if not found:
  print(-1)
  


Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
k = int(input())
ok = [0]*k
x=7 % k
ok[x] = 1
if x == 0:
  print(1)
else:
  now = 1
  while now+=1:
    x = x*10 +7
    if ok[x] == 1:
      print(-1)
      break
    elif x == 0:
      print(now)
      break

k = int(input())
ok = [0]*k
x=7 % k
ok[x] = 1
if x == 0:
  print(1)
else:
  now = 1
  while now+=1:
    x = (x*10 +7) % k
    if ok[x] == 1:
      print(-1)
      break
    elif x == 0:
      print(now)
      break


k = int(input())
ok = [0]*k
x=7 % k
ok[x] = 1
if x == 0:
  print(1)
else:
  now = 1
  while 1:
    now += 1
    x = (x*10 +7) % k
    if ok[x] == 1:
      print(-1)
      break
    elif x == 0:
      print(now)
      break
    else:
      ok[x] = 1


Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
k = int(input())
a = 0
for i in range(k):
  a = (a*10+7)/k
  if a == 0:
    print(i+1)
    brake
print(-1)


k = int(input())
a = 0
for i in range(k):
  a = a*10+7/k
  if a == 0:
    print(i+1)
    break
print(-1)

a=int(input())
 
if a%2 == 0:
  print(-1)
else:
  ans = 1
  div = 0
  
  for i in range(10**6):
    div += 7*10**i
    if a%div == 0:
      break
    else:
      ans +=1
  
  print(ans)

k = int(input())
a = 0
for i in range(k):
  a = (a*10+7)/k
  if a == 0:
    print(i+1)
    quit()
print(-1)

a=int(input())

if a%2 == 0:
  print(-1)
else:
  ans = 1
  div = 0
  
  for i in range(10**6):
    div += 7*10**i
    if a%div == 0:
      break
    else:
      ans +=1

print(ans)

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

k = int(input())
a = 0
for i in range(k):
  a = (a*10+7)%k
  if a == 0:
    print(i+1)
    quit()
print(-1)


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Runtime Error

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
k = int(input())
b = 7
c = 1
a = []
e = 0
a.append(7)
if(k%2 == 0):
  print(-1)
else:
  while(b%k != 0):
    r = b%k
    b = 10*r+7
    c += 1
    if b in a:
      e = 1
  	a.append(b)
  if(e == 1):
    print(-1)
  else:
  	print(c)

  


k = int(input())
b = 7
c = 1
a = []
a.append(7)
if(k%2 == 0):
  print(-1)
else:
  while(b%k != 0):
    r = b%k
    b = 10*r+7
    c += 1
    if(c > k):
      print(-1)
    else:
      print(c)

k = int(input())
b = 7
c = 1
a = []
a.append(7)
if(k%2 == 0):
  print(-1)
else:
  while(b%k != 0):
    r = b%k
    b = 10*r+7
    c += 1
    if b in a:
      print(-1)
  	a.append(b)
  print(c)
  


k = int(input())
c = 1
for i in range(1,n):
  a = 7*((10**i - 1)//9)
  if(a%k == 0):
    break
  else:
    c += 1
print(c)


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

Verdicts: Runtime Error

Wrong Answer

Runtime Error

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
k = int(input())

n = 7

if k % 2 == 0:
    print(-1)
else:
    for i in range(10*8):
        if n % k == 0:
            print(len(list(str(n))))
            break
        else:
            n = n*10 + 7
print(-1)
            


k = int(input())

n = 7

while n < 10**8:
    if n % k == 0:
        print(len(list(str(n))))
        break
    n = n*10 + 7

print(-1)
            


import sys
def main():
    k = int(input())

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

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

    print(-1)
    
main()

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
K=int(input())

L=9*K/7 if K%7==0 else 9*K

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

else:
    surplus=1
    for i in range(1,L):
        surplus=(surplus*10)%L
        if surplus==1:
            print(i)
            break
    print('-1')

K=int(input())

L=9*K//7 if K%7==0 else 9*K

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

else:
    surplus=1
    for i in range(1,L):
        surplus=(surplus*10)%L
        if surplus==1:
            print(i)
            break

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
k=int(input())
 
 
init=7
for i in range(k+1):
  if init%k ==0:
    print(i+1)
    break
  t = t*10+7
print(-1)

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

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
K=int(input())
s=0

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


K=int(input())
s=0

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


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
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
        if preva = firsta:
            ans = -1
    print(ans)

K = int(input())
def check(k):
    aaa = 0
    prev = 7%k
    for i in range(0,k):
        aaa+=1
        if prev == 0:
            return(aaa)
        prev = (prev*10+7)%k
    return(-1)
print(check(K))

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
K = int(input())

res = -1
count = 1
ai = 0
while(True):
    ai = (ai*10 + 7) % K
    count += 1
    if(ai == 0):
        res = count
        break

print(res)


K = int(input())

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

res = -1
count = 0
ai = 0
while(True):
    ai = (ai*10 + 7) % K
    count += 1
    if(ai == 0):
        res = count
        break

print(res)


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
k=int(input())
if k%2==0 or k%5==0:
  print(-1)
else:
  if k%7==0:
    k=k//7
  t=1
  tm=0
  for i in range(1,100000):
    tm=tm+t%k
    if tm==0:
      print(i)
      break
    else:
      t=t*10
  else:
    print(k-1)


k=int(input())
if k%2==0 or k%5==0:
  print(-1)
else:
  t=7
  ans=1
  while True:
    if t%k==0:
      print(ans)
      break
    t=(t*10+7)%k
    ans=ans+1


Verdicts: Time Limit Exceeded

Accepted
Problem: 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.

Submission attempts (in order):
import math
K=input()

if K%7==0:
    L=9*K/7
else:
    L=9*K

if L%2==0 or L%5==0:
    print(-1)
else:
    r=10%L
    for i in range(1,10**6+1):
        if r==1:
            ans=i
            break
        else:
            r=10*r%L

print(ans)

import math
K=input()

if K%7=0:
    L=9*K/7
else:
    L=9*K

if L%2=0 or L%5=0:
    print(-1)
else:
    r=10%L
    for i in range(1,10**6+1):
        if r==1:
            ans=i
            break
        else:
            r=10*r%L

print(ans)

import math
K=int(input())

if K%7==0:
    L=9*K//7
else:
    L=9*K

if L%2==0 or L%5==0:
    ans=-1
else:
    r=10%L
    for i in range(1,10**6+1):
        if r==1:
            ans=i
            break
        else:
            r=10*r%L
print(ans)


Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
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()


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) % K)
    for i in range(K + 1):
        if ret[i] == 0:
            print(i + 1)
            exit()
    else:
        print(-1)


if __name__ == '__main__':
    main()


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
import sys

def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
#======================================================#
def main():
    k = II()
    print(-1)

if __name__ == '__main__':
    main()

import sys

def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
#======================================================#
def main():
    k = II()
    sevens = 7%k
    for i in range(1, k+1):
        if sevens % k == 0:
            print(i)
            return
        sevens = (10*sevens + 7)%k
    print(-1)

if __name__ == '__main__':
    main()

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
k = int(input())

if k % 2 == 0 or k % 5 ==0:
  print(-1)
else:
  n = 7
  cnt = 1
  for i in range(k):
    n = (n * 10 +7) % k
    if n % k==0:
      break
      
    cnt +=1
    
print(cnt)    
    
    

k = input()
nana = int((len(k)-1)*'7')
ans = len(k)
k = int(k)
flag = False

def is_prime(q):
    q = abs(q)
    if q == 2:
        return True
    if q < 2 or q & 1 == 0:
        return False
    return pow(2, q-1, q) == 1


if is_prime(k):
    print(k-1)
else:
    for i in range(10000000):
        nana = (nana * 10) + 7
        if nana % k == 0:
            flag = True
            break
        ans += 1

    if flag:
        print(ans)
    else:
        print('-1')


# -*- coding: utf-8 -*-
k = int(input())
ans = 0
n = 7

if k % 2 == 0 or k % 5 == 0:
    print(-1)
    exit(0)
c = 1
while True:
    if n % k == 0:
        break
    n = (n * 10 + 7) % k
    c += 1

print(c)


Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
n = input()
m = 0

if n[-1] == "1":
    m = 7
elif n[-1] == "3":
    m = 9
elif n[-1] == "7":
    m = 1
elif n[-1] == "9":
    m = 3
else:
    print(-1)
    exit()

n = int(n)

for i in range(1, k):
    if len(set(list(str(n * m)))) == 1:
        break
    m = int(str(i) + str(m)[-1])
    if len(str(n * m)) >= k:
        print(-1)
        exit()

print(len(str(n * m)))


k = int(input())
m = 0

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

print(i + 1)


Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
k = int(input())
m = 7
if(k%2==0):
  print("-1")
else:
  i = 1
  while True:
    m = m%k
    if(j==0):
      print(i)
      break  
    if(i>k):
      print("-1")
      break
    m *= 10
    m += 7
    i += 1



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

  
  


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

  
  

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

  
  


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

  
  


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

  
  


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




Verdicts: Runtime Error

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Time Limit Exceeded

Accepted
Problem: 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.

Submission attempts (in order):
K = int(input())

i = 7%K
se = set(i)
cnt = 1
while True:
  if i == 0:
    print(cnt)
    break
  cnt += 1
  i = (i*10 + 7)%K
  if i in se:
    print(-1)
    break
  else:
    se.add(i)
  

K = int(input())

i = 7%K
se = set([i])
cnt = 1
while True:
  if i == 0:
    print(cnt)
    break
  cnt += 1
  i = (i*10 + 7)%K
  if i in se:
    print(-1)
    break
  else:
    se.add(i)
  

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
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)

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

for i,n in enumerate(x):
  if n == 0:
    print(i + 1)
    exit()
print(-1)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):

# C - Repsept

K=int(input())

modsevens=[7]

if K==7 or 1:
    print(1)
    exit()


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

print(-1)


# C - Repsept

K=int(input())

modsevens=[7]

if K==7 or K==1:
    print(1)
    exit()
else:
    pass

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

print(-1)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
K = int(input())

X = 10
ans = 1

if 
while ans <= 9000000:
    x = X%(9*K)
    if x == 1:
        print(ans)
        break
    else:
        ans += 1
        X = x*10 

if x != 1:
    print(-1) 

K = int(input())

X = 10
ans = 1    
while ans <= L:
    L = 9*K/7
    x = X%L
    if x == 1:
        print(ans)
        break
    else:
        ans += 1
        X = x*10 

if x != 1:
    print(-1) 

K = int(input())

n = 7
i = 1

while i <= K:
    if n%K == 0:
        ans = i
        break
    n = n*10 + 7
    i += 1
    
else:
    print(-1)

K = int(input())

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

K = int(input())

ans = 1
X = 7
cnt = K
while ans <= K:
    x = X % K
    if rem == 0:
        print(ans)
        break
    else:
        ans += 1
        X = x*10 + 7 

if rem != 0:
    print(-1)

K = int(input())

ans = 1
X = 7
cnt = K
while ans <= K:
    x = X % K
    if x == 0:
        print(ans)
        break
    else:
        ans += 1
        X = x*10 + 7 

if x != 0:
    print(-1)

Verdicts: Runtime Error

Runtime Error

Wrong Answer

Wrong Answer

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
K = int(input())


if K%2==0:
    mod = -1
else:
    flag=0
    mod = 7
    count = 1
    while flag==0:
        if mod==0:
            flag = 1
        else:
            count += 1
            mod = (mod*10+7) % K

print(mod)

K = int(input())


if K%2==0 or K%5==0:
    count = -1
else:
    flag=0
    mod = 7
    count = 1
    while mod%K!=0:
        count += 1
        mod = (mod*10+7) % K

print(count)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
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')
    

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


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
k=input()
ans=7
ans2=10
prev=7
if ans%k==0:
    print(1)
else:
    for i in range(0, k + 1, 1):
        ans=7*ans2+prev
        if ans%k==0:
            print(i+2)
            break
        prev=ans
        ans2=ans2*10



k=int(input())
ans=7
ans2=10
prev=7
hbe=False
if ans%k==0:
    print(1)
    hbe=True
else:
    for i in range(0, k + 1, 1):
        ans=(7*ans2+prev)%k
        if ans%k==0:
            print(i+2)
            hbe=True
            break
        prev=ans
        ans2=(ans2*10)%k
if hbe==False:
    print(-1)



Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
k = int(input())
n = 7
m = 7
if(k%2==0):
  print(-1)
elif(k ==999983):
  print("999982")
else:
  for i in range(10**6+1):
    n = (7 +n*10)%k
    if(n==0):
      print(i+1)
      break

k = int(input())
n = 7
m = 7
if(k%2==0):
  print(-1)
elif(k ==999983):
  print("999982")
else:
  for i in range(10**6+1):
    n = (n +7*10**(i+1))%k
    if(n==0):
      print(i+1)
      break

K = int(input())
N = 10
a = 0
l = 9*K
if(K==7 or K==1):
  a+=1
  print(1)
else:
  for i in range(1,10**6):
    N = (10*N)%l
    if (N*7-7)%l==0:
      print(i+1)
      a +=1
      break
  if(a == 0):
    print(-1)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
K = int(input())

if K % 2 == 0　or K % 5 == 0:
  print(-1)
else:
  if K % 7 == 0:
    L = 9 * K // 7
  else:
    L = 9 * K
  a = 10 % L
  check = False
  for i in range(L):
    a %= L
    if a == 1:
      print(i + 1)
      check = True
      break
    a *= 10
  if not check:
    print(-1)

K = int(input())

if K % 2 == 0 or K % 5 == 0:
  print(-1)
else:
  if K % 7 == 0:
    L = 9 * K // 7
  else:
    L = 9 * K
  a = 10 % L
  check = False
  for i in range(L):
    a %= L
    if a == 1:
      print(i + 1)
      check = True
      break
    a *= 10
  if not check:
    print(-1)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
K = int(input())

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

K = int(input())

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

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
N = int(input())

mod_list = []
if N % 2:
    i = 1
    while True:
        num = (7*((10**i)-1)/9) % N
        if num == 0:
            print(i)
            break
        if num in mod_list:
            print(-1)
            break
        else:
            mod_list.append()
            i += 1

else:
    print(-1)


N = int(input())
if N % 7:
    L = 9*N
else:
    L = 9*N//7
num = 1
if L % 2 and L % 5:
    i = 1
    while i <= L:
        num = (num*10) % L
        if num == 1:
            print(i)
            break

        else:

            i += 1

else:
    print(-1)


Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
K = int(input())

N = 0

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

K = int(input())

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

K = int(input())

N = 0

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


K = int(input())

N = 0

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


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)


K = int(input())

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

K = int(input())

N = 0

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

K = int(input())

N = 0

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


K = int(input())

num = 7%K

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

Verdicts: Wrong Answer

Runtime Error

Wrong Answer

Wrong Answer

Wrong Answer

Runtime Error

Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
def main():
    K = int(input())
    if K%10:
        L = 9*K if K%7 else 9*K//7
        mod = 10%L
        for i in range(9000001):
            if mod == 1:
                print(i)
                exit()
            mod = 10*mod%L
    else:
        print(-1)
    

if __name__ == "__main__":
    main()

def main():
    K = int(input())
    if K%10:
        if K%7==0:
            K//=7
        L = 9*K
        mod = 10%L
        for i in range(9000001):
            if mod == 1:
                print(i+1)
                exit()
            mod = 10*mod%L
        print(-1)
    else:
        print(-1)
    

if __name__ == "__main__":
    main()

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
n = int(input())
seen = set()
ans = 0
res = 7%n
seen.add(res)
ans += 1
while res != 0:
	new = (res*10 + 7)%n
    if new not in seen:
		seen.add(new)
        res = new
        ans += 1
	else:
    	print(-1):
        exit()
print(ans)

k = int(input())
ans = 1
seen = set()
mod = 7%k
while mod != 0 and mod not in seen:
    seen.add(mod)
    mod = (10*mod + 7)%k
    ans += 1

if mod == 0:
    print(ans)
else:
    print(-1)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
import sys
k = int(sys.stdin.read())
k *= 9
limit = 1000000
value = 0
index = 0
while index < limit:
  index += 1
  value = (value*10+7)%k
  if value == 0:
    print(index)
    sys.exit()

print(-1)

import sys
k = int(sys.stdin.read())
if k==2:
  print(-1)
  sys.exit()
value = 0
index = 0
while index < 1000000:
  index += 1
  value = (value*10+7)%k
  if value == 0:
    print(index)
    sys.exit()

print(-1)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
K=int(input())
m=0
count=1
for i in range(K):
	m=(m*10+7)%K
	if m==0:
		print(count)
		break
	count+=1
print(-1)

K=int(input())

seven=0
m=1
while m!=0:
	seven=seven*10+7
	m=seven % K

print(seven)

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

if chk==0:
	print(-1)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
K = int(input())
A = 7 % K 

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

K = int(input())
A = 7 % K 

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

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
k = int(input())
cnt = 0
mod = [0]
not_found = 1
while cnt<k+1:
    cnt+=1
    n = mod[-1]*10+7
    mod.append(n%k)
    if n % k == 0:
        not_found = 0
        print(cnt)
if(not_found):
    print(-1)


k = int(input())
cnt = 0
mod = [0]
while cnt<k:
    cnt+=1
    n = mod[-1]*10+7
    mod.append(n%k)
    if n % k == 0:
        print(cnt)

k = int(input())
cnt = 0
mod = [0]
not_found = 1
while cnt<k:
    cnt+=1
    n = mod[-1]*10+7
    mod.append(n%k)
    if n % k == 0:
        not_found = 0
        print(cnt)
if(not_found):
    print(-1)

k = int(input())
cnt = 0
mod = [0]
not_found = 1
while cnt<k+1:
    cnt+=1
    n = mod[-1]*10+7
    mod.append(n%k)
    if n % k == 0:
        not_found = 0
        print(cnt)
        break
if(not_found):
    print(-1)


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
def solution(K: int) -> int:
    sevens: int = 0
    for i in range(1, K + 1):
        print(sevens)
        sevens = (sevens*10 + 7) % K
        if sevens == 0:
            return i
    return -1


K: int = int(input())

print(solution(K))


def solution(K: int) -> int:
    ans: int = 0
    x: int = 7
    while True:
        print(x)
        print()
        ans += 1
        
        if K % 2 == 0:
            return -1
        
        if x < int(K):
            x: int = int(str(x) + str(7))
            continue
        if x % K == 0:
            return ans
        x: int = int(str(x) + str(7))
    return ans


K: int = int(input())

print(solution(K))


def solution(K: int) -> int:
    sevens: int = 0
    for i in range(1, K + 1):
        sevens = (sevens*10 + 7) % K
        if sevens == 0:
            return i
    return -1


K: int = int(input())

print(solution(K))


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
k = int(input())
t = 7
ans=0
for i in range(k):
  if t%k==0:
    ans=i+1
  	break
  else:
    t = (t*10+7)%k
        
if ans >0:
  print(ans) 
else:
  print(-1)

k = int(input())
t = 7
ans=0
for i in range(k):
    if t%k==0:
        ans=i+1
        break
    else:
        t = (t*10+7)%k
        
if ans >0:
    print(ans) 
else:
    print(-1)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
#C
K = int(input())
judge=False
num = 0
for i in range(K+1):
    num += 7 * (10**i)
    num == num % K
    if num == 0:
        judge=True
        print(i+1)
        break
if judge == False:print("-1")

#C
K = int(input())
judge=False
num = 7
for i in range(K):
    num = num % K
    #print(num)
    if num == 0:
        print(i+1)
        judge = True
        break
    else:
        num = num*10+7
if judge == False:print("-1")

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
import math
def is_prime(n):
    if n == 1: return False
    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True

K = int(input())
if K==1:
    print(1)
if K==2:
    print(-1)
elif K==3:
    print(3)
elif K==5:
    print(-1)
elif K==7:
    print(1)
elif K==11:
    print(2)
elif K==77:
    print(2)
elif K==111:
    print(3)
elif K==777:
    print(3)
elif K==1111:
    print(4)
elif K==7777:
    print(4)
elif K==11111:
    print(5)
elif K==77777:
    print(5)
elif K==111111:
    print(6)
elif K==777777:
    print(6)
elif K==1111111:
    print(7)
elif K==7777777:
    print(7)
elif is_prime(K):
    print(K-1)
else:
    print(-1)

import math
def is_prime(n):
    if n == 1: return False
    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True

K = int(input())

ans = 0
flag = 0
new = 7
for i in range(K):
    ans = (ans + new%K)%K
    if ans % K == 0:
        flag = 1
        break
    #print(i,ans,new)
    new = (new*10)%K
if flag==0:
    print(-1)
else:
    print(i+1)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
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()


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 + 1
      break
  print(ans)

if __name__ == '__main__':
  main()


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
from collections import deque
N= int(input())
state = input()
 
newlist = sorted(state)
goalstate = "".join(newlist)
uni = 0
for l in range(len(goalstate)):
    if goalstate[l] == "W":
        uni = l
        break
def bfs(state,goalstate):
    cur_state = deque([state])
    cou = 0
    while cur_state:
        cur = cur_state.popleft()
        if cur == goalstate:
            return cou
            break
        new= list(cur)
        temp = 0
        for i in range(len(goalstate)):
            if new[i] == "W":
                temp = i
                break
        neow= 0
        for j in range(uni-1,len(goalstate)):
            if new[j] == "R":
                neow = j
                break
        tempstr = new.pop(temp)
        temp1str = new.pop(neow-1)
        new.insert(neow,tempstr)
        new.insert(temp,temp1str)
        nowstr = "".join(new)
        cur_state.append(nowstr)
        cou += 1
 
 
goal = bfs(state, goalstate)
print(goal)

N= int(input())
state = input()

newlist = sorted(state)
goalstate = "".join(newlist)

uni = 0
for l in range(len(goalstate)):
    if goalstate[l] == "W":
        uni = l
        break

def bfs(state,goalstate):
    cur_state = deque([state])
    cou = 0
    while cur_state:
        cur = cur_state.popleft()
        if cur == goalstate:
            return cou
            break
        new= list(cur)
        temp = 0
        for i in range(len(goalstate)):
            if new[i] == "W":
                temp = i
                break
        neow= 0
        for j in range(uni-1,len(goalstate)):
            if new[j] == "R":
                neow = j
                break
        tempstr = new.pop(temp)
        temp1str = new.pop(neow-1)
        new.insert(neow,tempstr)
        new.insert(temp,temp1str)
        nowstr = "".join(new)
        cur_state.append(nowstr)
        cou += 1


goal = bfs(state, goalstate)
print(goal)

K = int(input())
if K % 2 == 0 or K % 5 == 0:
  print(-1)
else: 
    state = 7 
    state %= K
    cou = 1
    while True:
        if state == 0:
            print(cou)
            break
        state = state *  10 + 7
        state %= K 
        cou+= 1

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
# coding: utf-8


k = 999983
befo = 0

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


# coding: utf-8

k = int(input())
n = 7 % k

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


Verdicts: Time Limit Exceeded

Accepted
Problem: 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.

Submission attempts (in order):
K = int(input())

flag = [0 for _ in range(K)]  

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


K = int(input())

flag = [0 for _ in range(K)]  

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


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
k = int(input())
if k % 2 == 0 or k % 5 == 0:
    print(-1)
    exit()

i = 7
cnt = 1
while i != 0:
    i = i * 10 + 7
    i %= 7
    cnt += 1
print(cnt)


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

i = 7 % k
cnt = 1
while i != 0:
    i = i * 10 + 7
    i %= k
    cnt += 1
print(cnt)


Verdicts: Wrong Answer

Accepted