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):
k=int(input())

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

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

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

k=int(input())

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

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

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

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

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

Verdicts: Runtime Error

Wrong Answer

Wrong Answer

Runtime Error

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

      break
print("cnt=",cnt)

n,d = list(map(int, input().split()))
c=0
d *= d
for i in range(n):
  x,y = list(map(int, input().split()))
  x *= x
  y *= y
  y += x
  if y <= d:
    c += 1
print(c)

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)

for j in range(999999):
  d2 = 7 - mae % 10
  s = str(sd[d2] * k + mae)

#  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)
      break
#    print("i= ",i)
    if i == 0 :
      print(cnt)
      exit()

Verdicts: 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 or k%5==0:
  print(-1)
  exit()

num=7
num%=k
ans=1

while k!=0:
  num=(10*num+7)%k+7

print(ans)

k=int(input())

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

ans=1
num=7
while num%k!=0:
  num=10*num+7
  num%=k
  ans+=1

print(ans)

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):
a = 7
b = int(inout())

list = [7]
for i in range(b):
    list.append(list[-1]*10 +7)

for l in range(len(list)):
    if list[l] % b == 0:
        print(l+1)
        exit()


s = 7
a = int(input())

for i in range(10**6):
    if s%a == 0:
        print(i+1)
        exit()
    s = (s*10+7) % a
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 numpy as np
K=int(input()) 

S=""
count=-1

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

print(count)

import numpy as np
K=int(input()) 

S=""
count=-1

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

print(count)

import numpy as np
K=int(input()) 

S=0
count=-1

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

print(count)

Verdicts: 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):
import sys
k = int(input())

remainders = set()
current_remainder = 7 % k
remainders.add(current_remainder)

counter = 1
while True:
    counter += 1
    remainder = remainder * 10 % k
    if remainder in remainders:
        print('-1')
        sys.exit()
    remainders.add(remainder)
    print(remainders)
    if sum(remainders) % k == 0:
        print(counter)
        sys.exit()

import sys
k = int(input())

remainders = set()
remainder = 7 % k
remainders.add(remainder)

counter = 1
while True:
    counter += 1
    remainder = remainder * 10 % k
    if remainder in remainders:
        print('-1')
        sys.exit()
    remainders.add(remainder)
    print(remainders)
    if sum(remainders) % k == 0:
        print(counter)
        sys.exit()

import sys
k = int(input())

remainders = set()
current_remainder = 7 % k
remainders.add(current_remainder)

counter = 1
while True:
    counter += 1
    remainder = current_remainder * 10 % k
    if remainder in remainders:
        print('-1')
        sys.exit()
    remainders.add(remainder)
    if sum(remainders) % k == 0:
        print(counter)
        sys.exit()

import sys

k = int(input())
n = 7
counter = 1
remainders = set()

while True:
    remainder = n % k
    if remainder == 0:
        print(counter)
        sys.exit()
    if remainder in remainders:
        print(-1)
        sys.exit()
    remainders.add(remainder)
    
    n = remainder * 10 + 7
    counter += 1

Verdicts: Runtime Error

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):
def solve(k):
    a_mod = 0
    for i in range(1000000):
        a_mod += 7 * pow(10, i, k)
        a_mod %= k
        if a_mod == 0:
            return i + 1
    return -1


def main():
    k = int(input())
    res = solve(k)
    print(res)


def test():
    assert solve(101) == 4
    assert solve(2) == -1
    assert solve(999983) == 999982


if __name__ == "__main__":
    test()
    main()


def solve(k):
    a_mod = 0
    pow_10 = 7
    for i in range(1000000):
        a_mod += pow_10
        a_mod %= k
        if a_mod == 0:
            return i + 1
        pow_10 *= 10
        pow_10 %= k
    return -1


def main():
    k = int(input())
    res = solve(k)
    print(res)


def test():
    assert solve(101) == 4
    assert solve(2) == -1
    assert solve(999983) == 999982


if __name__ == "__main__":
    test()
    main()


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())
if K % 2 == 0:
    print(-1)

a = 0
for i in range(K):
    a = 7 * 10**(i) + a
    if a % K == 0:

      print(i)
      break

    else:
      continue

K = int(input())

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

a = 0
if K < 900000:
  for i in range(K):
    a = 7 * 10**(i) + a
    if a % K == 0:
      print(i)
      break
elif K >= 900000:
  print(999982)

K = int(input())

def func(K):
  a = 0
  for i in range(1, K+1):
    a = (a * 10 + 7) % K
    
    if a == 0:
      return i
  return -1

print(func(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):
#!/usr/bin/env python3

k = int(input())

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

d1 = k % 10
print(d1)
if d1 != 1 and d1 != 7 and d1 != 3 and d1 != 9:
    print(-1)
    #print("b")
    exit(0)

def PrimeJudge(n):
    ret = True
    for i in range(2, int(n ** 0.5)+1):
        if n % i == 0:
            ret = False
            break
    return ret

if PrimeJudge(k) == False:
    print(-1)
    #print("c")
    exit(0)

s = 7
while(1):
    i = int(s)
    if i < k:
        s = str(s)+'7'
    else:
        if i % k == 0:
            print(len(s))
            exit(0)
        else:
            s = str(s)+'7'





#!/usr/bin/env python3

k = int(input())

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

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())
ans = 0
ai = 7
for i in range(k):
    ai = ((ai * 10) + 7) % k
    if ai == 0:
        ans = i
        break
    if i == k:
        ans = -1

print(ans)



k = int(input())
ans = 0

ai = 0
for i in range(k+2):
    ai = ((ai * 10) + 7) % k
    if ai == 0:
        ans = i + 1
        print(ans)
        exit()

ans = -1
print(ans)




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())
k *= 9
amari = 63
for i in range(1, 10 ** 6 + 1):
  amari %= k
  if amari == 0:
    print(i)
    break
  else:
    amari = amari * 70 + 63
else:
  print(-1)

k=int(input())
k *= 9
amari = 63
for i in range(1, 10 ** 6 + 1):
  amari %= k
  if amari == 0:
    print(i)
    break
  else:
    amari = amari * 10 + 63
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):
import math
x = int(input())
if math.gcd(x, 10) != 1:
	print(-1)
	exit()
phi = x
q = x
l = q	
for i in range(3, int(math.sqrt(l)) + 1, 2):
	if q % i == 0:
		phi //= i
		phi *= (i - 1)
		while q % i == 0:
			q //= i
if q != 1:
	phi //= q
	phi *= (q - 1)
print(phi)

import math
x = int(input())
rem = 7 % x
cnt = 1
while rem != 0 and cnt <= 1000000:
	rem = (10 * rem + 7) % x
	cnt += 1
if rem == 0:
	print(cnt)
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):
K = int(input())
if K%2==0 or K%5==0:
  print(-1)
else:
  n = 1
  while True:
    if 7*(10**n-1)/9%K==0:
      print(n)
      break

K = int(input())
if K%2==0 or K%5==0:
  print(-1)
else:
  n = 1
  Rem = 7%K
  while Rem!=0:
    Rem = (Rem*10+7)%K
    n+=1
  print(n)

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):
N=int(input())

def waru(N):
    if N%2==0:
        print("-1")
        return
    a="7"
    for i in range(1,100000000):
        ia=int(a)
        if N>ia:
            a+="7"
            continue
        if N%ia==0:
            print(i)
            return
        a+="7"

    print("-1")

waru(N)

K=int(input())
def waru(K):
    a=[]
    if K%2==0 or K%5==0:
        print("-1")
        return
    a.append(7%K)
    for i in range(1,K):
        a.append((10*a[i-1]+7)%K)
    for i in range(K):
        if a[i]==0:
            print(i+1)
            return
    print(-1)
waru(K)

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

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

for i in range(1, 10**12):
    n = int(('7'*i))
    print(n)
    if n%k == 0:
        print(i)
        exit(0)

print(-1)

k = int(input())

m = 0

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

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())
mod = []
a[0] = 7%K
if a[0] == 0:
    print(a[0])
    exit()
for i in range(1,K+1):
    a[i] = (a[i-1]*10 + 7)%K
    if a[i] == 0:
        print("%d",a[i])
        break

else:
    print(-1)

K = int(input())
k = str(K)
num = -1

if K % 2 == 0:
    print("-1")
else:
    while True:
        num += 1
        zoro = [7] * (len(k)+num)
        zorome = int(''.join(map(str, zoro)))
        print(num)

        if zorome % K ==0:
            print(len(k)+num)
            break

K = int(input())
mod = []
a[0] = 7%K
if a[0] == 0:
    print(a[0])
    exit()
for i in range(1,K):
    a[i] = (a[i-1]*10 + 7)%K
    if a[i] == 0:
        print("%d",a[i])
        break

else:
    print(-1)

K = int(input())
mod = []
a[0] = 7%K
for i in range(1,K):
    a[i] = (a[i-1]*10 + 7)%K

for i in range(K):
    if a[i] == 0:
        print("%d",a[i])
        break

else:
    print(-1)

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)

K = int(input())
mod = []
a[0] = 7%K
for i in range(1,K):
    a[i] = (a[i-1]*10 + 7)%K
 
for i in range(K):
    if a[i] == 0:
        print(a[i])
        break
 
else:
    print(-1)

K = int(input())

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

else:
    print(-1)

Verdicts: Runtime Error

Wrong Answer

Runtime Error

Runtime Error

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):
def euclid(a, b):
    if b == 0:
        return a
    else:
        return euclid(b, a%b)

def main():

    k = int(input())
    if k % 2 == 0:
        print('-1')
    else:
        for i in range(1, k + 1):
            target = int('1' * i) * 7
            if euclid(target, k) != 1:
                print(target)

if __name__ == '__main__':
    main()

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

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

def main():

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

if __name__ == '__main__':
    main()

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):
k= int(input())
 
if k % 2 == 0 or k % 5 == 0:
    print("-1")
    
else:
    ans = 1
    s = ７
    while True:
        if s % k == 0:
            print(ans)
            break
        else:
            s = (s % k)*10 + 7
            ans += 1

k= int(input())
 
if k % 2 == 0 or k % 5 == 0:
    print("-1")
    
else:
    ans = 1
    s = 7
    while True:
        if s % k == 0:
            print(ans)
            break
        else:
            s = (s % k)*10 + 7
            ans += 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):
def main():
    k = int(input())
    init = 7%k
    an = [init]
    for _ in range(k):
        a = an[-1]
        an.append((10*a+7) % k)

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

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

    for ind, a in enumerate(an):
        if a==0:
            print(ind+1)
            return
    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):
i = 0;
mod = 0;
while True:
    mod = (mod*10 + 7) % k;
    if mod == 0:
        break;
    i += 1;
    if i == k:
        j = -2
        break;

print(i+1)

k = int(input())


i = 0;
mod = 0;
while True:
    mod = (mod*10 + 7) % k;
    print(mod)
    if mod == 0:
        break;
    i += 1;
    if i == k:
        i = -2
        break;

print(i+1)

k = int(input())


i = 0;
mod = 0;
while True:
    mod = (mod*10 + 7) % k;
    if mod == 0:
        break;
    i += 1;
    if i == k:
        i = -2
        break;

print(i+1)

Verdicts: 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):
import sys
def input():
    return sys.stdin.readline()[:-1]


def main():
    K = int(input())
    x = 0
    if K % 2 == 0 or K % 5 ==  0:
        print(-1)
  
    while True:
        x = (x * 10 + 7) % K
        i += 1
        if x == 0:
            print(i + 1)
            break


    

if __name__ == "__main__":
    main()

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


def main():
    K = int(input())
    x = 0
    i = 0
    if K % 2 == 0 or K % 5 ==  0:
        print(-1)
        exit()
    
    while True:
        x = (x * 10 + 7) % K
        i += 1
        if x == 0:
            print(i)
            break


    

if __name__ == "__main__":
    main()

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
count=1
flag=0
for i in range(K):
  if m%K==0:
    flag=1
    break
  else:
    m*=10
    m+=7
    m%=K
    count+=1
if flag:
  print("-1")
else:
  print(count)

K=int(input())
m=7
count=1
flag=0
for i in range(K):
  if m%K==0:
    flag=1
    break
  else:
    m*=10
    m+=7
    m%=K
    count+=1
if not flag:
  print("-1")
else:
  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())

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

a = [7]
ans = 0
for i in a:
  if i % k == 0:
    ans += 1
    break
  else:
    a += [i*10 + 7]
    ans += 1
    

k = int(input())

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

a = [7]
ans = 0
for i in a:
  if i % k == 0:
    ans += 1
    break
  else:
    a = [i*10 + 7]
    ans += 1


print(ans)


k = int(input())

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

a = [7]
ans = 0
for i in a:
  if i % k == 0:
    ans += 1
    break
  else:
    a = [i*10 + 7]
    ans += 1
    print(a)

print(ans)


k = int(input())

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

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


print(ans)


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):
import copy

# a = get_int()
def get_int():
    return int(input())

# a = get_string()
def get_string():
    return input()


def get_int_list():
    return [int(x) for x in input().split()]


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


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


def get_string_char_list():
    return list(str(input()))

# print("{} {}".format(a, b))
# for num in range(0, a):
# a_list[idx]
# a_list = [0] * a
'''
while (idx < n) and ():

    idx += 1
'''

def main():
    k = get_int()
    ret = -1


    for i in range(1,k*5):
        wk = k * i
        strwk = str(wk)

        if (strwk.count("7") == len(strwk)):
            ret = wk
            break

    print(ret)




if __name__ == '__main__':
    main()




import copy

# a = get_int()
def get_int():
    return int(input())

# a = get_string()
def get_string():
    return input()


def get_int_list():
    return [int(x) for x in input().split()]


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


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


def get_string_char_list():
    return list(str(input()))

# print("{} {}".format(a, b))
# for num in range(0, a):
# a_list[idx]
# a_list = [0] * a
'''
while (idx < n) and ():

    idx += 1
'''

def main():
    k = get_int()
    prev = 7 % k
    ret = -1

    amari = prev

    if amari == 0:
        ret = 1
    else:

        for i in range(1, k):
            prev = (prev * 10) % k
            amari = (amari + prev) % k

            if amari == 0:
                ret = i+1
                break

    print(ret)


def check(bunshi, k):
    return (bunshi % k == 0)


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



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


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()
keta = len(K)
k=int(K)
if k%2==0:
  print(-1)
else:
  seven = "7"*keta
  s = int(seven)
  ans=0
  while (1):
    ans+=1
    s = s%k
    if s==0:
      print(ans)
      break
    else:
      s = s*10+7

k=int(input())
if k%2==0 or k%5==0:
  print(-1)
else:
  s=7
  for i in range(k):
    if s%k==0:
      print(i+1)
      exit()
    else:
      s=(s*10+7)%k


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):
print(999983 * 7) 
print(999983 * 17)
print(999983 * 817)
print(999983 * 5817)
print(999983 * 75817)
print(999983 * 875817)
print(999983 * 3875817)
print(999983 * 23875817)


N = int(input())

mod_first = 7 % N
mod_next = mod_first * 11 % N

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

for i in range(10000000):
    mod_next = (mod_next * 10 + mod_first) % N
    if mod_next == 0:
        print(i + 3)
        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())
count=1
if k%2==0:
  print(-1)
else:
  while True:
    if a%k==0:
      print(count)
      break
    else:
      a=a*10+7
      count+=1


k=int(input())
a=0
for i in range(k):
  a=(a*10+7)%k
  if a==0:
    print(i+1)
    exit()
    
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())

flag=0　

a=7 
i=0 #index

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

else:
    while(flag==0):
        if(a%k==0):
            flag==1
        i += 1
        a=10*a+7

    print(i)

K=int(input())

a=7 
b=10
i=0 #index

if (K%7 == 0):
    L = 9*K/7
else:
    L = 9*K
    
if (L%2==0 or L%5==0):
    print(-1)
else:
    while(i<=L):
        if (b%L==1):
            break
        else:
            b=10*(b%L)
            i += 1
    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())
s = 7
if k%2 == 0:
	print(-1)
elif k%5 == 0:
	print(-1)
else:
	while s%k != 0:
		s = 10*s+7
		s = str(s)
	print(len(s))

k = int(input())
if k%2 == 0:
	print(-1)
elif k%5 == 0:
	print(-1)
else:
	s = 7
	while s%k != 0:
		s = 10*s+7
	print(len(s))

k = int(input())
if k%2 == 0:
	print(-1)
elif k%5 == 0:
	print(-1)
else:
	s = 7
	while s%k != 0:
		s = 10*s+7
	print(len(s))

k = int(input())
s = 7
if k%2 == 0:
	print(-1)
elif k%5 == 0:
	print(-1)
else:
	while s%k != 0:
		s = 10*s+7
	print(len(s))

k = int(input())
if k%2 = 0:
	print(-1)
elif k%5 = 0:
	print(-1)
else:
	s = 7
	while s%k != 0:
		s = 10*s+7
	print(len(s))

import sys

k = int(input())

a = 0

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

Verdicts: Runtime Error

Runtime Error

Runtime Error

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())
nana = [7,77,777,7777,77777,777777,7777777,77777777,777777777]
warikireta = 0
if K == 2 or K == 5:
  print(-1)
else:
  for i in range(9):
    if nana[i] % K == 0:
      warikireta = i + 1
    else:
      pass
if warikireta != 0:
  print(warikireta)
elif warikireta == 0:
  if K == 2:
    pass
  elif K == 5:
    pass
  else:
    print(-1)


import math
t = int(input())
if t%2==0 or t%5==0:
    print(-1)
else:
    i=1
    s=7
    while 1:
 
        if s%t==0:
            print(i)
            break
 
        else:
            i += 1
            s = (s * 10 + 7) % t
            continue

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())
amari_list = []
amari = 7%K
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:a
        print(-1)
        break
    if i == (K-1):
        print(-1)
    else:
        amari_list.append(amari)
        

K=int(input())
amari=0
for i in range(K):
    amari = (amari * 10 + 7)% K
    if amari == 0:
        print(i+1)
        break
    if i == (K-1):
        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())
x = 7%k
s = []
if k%2 == 0:
  print(-1)

else:
  while s.count(x) == 0:
    s.append(x)
    if x == 0:
      print(len(s))
      break
    x = (10*x + 7)%k

  
  if s.count(x) != 0:
    print(-1)

k = int(input())
x = 7%k
s = []

while x not in s:
  if x == 0:
    print(len(s+1))
    break
  s.append(x)
  x = (10*x + 7)%k

  
if s[-1] != 0:
  print(-1)


k = int(input())
x = 7%k
s = set()
while s.count(x) == 0:
  s.append(x)
  x = (10*x + 7)

k = int(input())
x = 7%k
s = []
if k%2 == 0:
  print(-1)

else:
  while s.count(x) == 0:
    s.append(x)
    if x == 0:
      print(len(s))
      break
    s.append(x)
    x = (10*x + 7)%k

  
  if s.count(x) != 0:
    print(-1)

k = int(input())
x = 7%k
s = []

for i in range(k):
  if x == 0:
    print(len(s+1))
    exit()
  s.append(x)
  x = (10*x + 7)%k

  
  
print(-1)


k = int(input())
x = 7%k
s = []

for i in range(k):
  if x == 0:
    print(len(i+1))
    exit()
  s.append(x)
  x = (10*x + 7)%k

  
  
print(-1)


k = int(input())
x = 7%k
s = []

while s.count(x) == 0:
  s.append(x)
  if x == 0:
    print(len(s))
    break
  x = (10*x + 7)%k

  
if s.count(x) != 0:
  print(-1)


k = int(input())
x = 7%k
s = set()
while s.count(x) == 0:
  s.append(x)
  x = (10*x + 7)%k

if s[-1] == 0:
  print(len(s))
else:
  print(-1)
  

k = int(input())
x = 7%k
s = []

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

  
  
print(-1)


Verdicts: Wrong Answer

Runtime Error

Runtime Error

Wrong Answer

Runtime Error

Runtime Error

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())
a = [None]*1000001
a[1]=7%k
n=0

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


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

if a[1]==0:
    print("1")
    n=1

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


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())
lis = []
c = 0
a = 0
while(True):
    a = (a*10 + 7) & k
    if a == 0:
        print(c+1)
        quit()
    if c > k:
        print(-1)
        quit()
    c += 1

k = int(input())
lis = []
c = 1
a = 0
while(True):
    a = (a*10 + 7) % k
    if a == 0:
        print(c)
        quit()
    if c > k:
        print(-1)
        quit()
    c += 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())
i = 0
ret = -1
if K % 5 != 0 and K % 2 != 0:
  N = 1
  if K % 7 == 0:
    L = K * 9 // 7
  else:
    L = K * 9
  while True:
    if N % L == 1:
      ret = i
      break
    N = (N * 10 )% L
    i += 1
print(ret)


K = int(input())
i = 1
ret = -1
if K % 5 != 0 and K % 2 != 0:
  N = 10
  if K % 7 == 0:
    L = K * 9 // 7
  else:
    L = K * 9
  while True:
    if N % L == 1:
      ret = i
      break
    N = (N * 10 )% L
    i += 1
print(ret)


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())
num = 0
ans = 0
seven = ''


for i in range(k):
    seven += '7'
    num = int(seven) % k
    if num == 0:
        ans = i
        break
print(ans)

k = int(input())
seven = 7
count = 0

def main():
    for i in range(1000000):
        if k % 2 == 0:
            count = -1
            return

        elif seven % k == 0:
            count += 1
            print(count)
            return
        else:
            count += 1
            seven = seven * 10 + 7
    print(-1)

if __name__ == '__main__':
    main()

k = int(input())
seven = ７
count = 0

while True:
    if k % 2 == 0:
        count = -1
        break

    elif seven % k == 0:
        count += 1
        break
    else:
        count += 1
        seven = seven * 10 + 7

print(count)

K = int(input())

ans = 1
X = 7
cnt = K

for _ in range(1000000):
    x = X % K
    if x == 0:
        print(ans)
        break
    else:
        ans += 1
        X = x*10 + 7

if x != 0:
    print(-1)

Verdicts: 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):
#200802C
X = int(input())
L = len(str(X))
#print(L)



for l in range(L):
    Y += 7*10**l
    
flag = 0
for i in range(10000000):
    Y = Y%X
    #print(i)

    if Y == 0:
        ans = L+i
        flag = 1
        break
    else: 
        Z = Y * 10 + 7
        if Z == Y:
            break
        else:
            Y = Z

if flag == 0:
    print("-1")
else:
    print(ans)


#200802C
X = int(input())
L = len(str(X))
#print(L)


Y = 0

for l in range(L):
    Y += 7*10**l
    
flag = 0
for i in range(1000000):
    Y = Y%X
    #print(i)

    if Y == 0:
        ans = L+i
        flag = 1
        break
    else: 
        Z = Y * 10 + 7
        if Z == Y:
            break
        else:
            Y = Z

if flag == 0:
    print("-1")
else:
    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())

n = 17
for i in range(n):
    if i == n-1:
        print(-1)
    elif int(7 * (10 ** (i + 1) - 1 ) / 9) % K == 0:
        print(i+1)
        break
print (int(7 * (10 ** (i + 1) - 1 ) / 9))

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

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

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)

K = int(input())





i, a = 0, 0
l = []
for i in range(K):
  a = (10*a + 7) % K
  l.append(a)

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

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:
    print(-1)

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

K = int(input())
remainder_set = set()
sequence = 7
i = 1
for i in range(10**7 + 9):
    if sequence%K == 0:
        print(i+1)
        break
    else:
        if sequence%K in emainder_set:
            print(-1)
            break
        else:
            i += 1
            sequence *= 10
            sequence += 7

K = int(input())

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

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

K = int(input())
remainder_set = set()
sequence = 7
i = 1
for i in range(K):
    remainder = sequence%K
    #print(sequence,remainder)
    if remainder == 0:
        print(i+1)
        break
    else:
        if remainder in remainder_set:
            print(-1)
            break
        else:
            i += 1
            remainder_set.add(remainder)
            sequence = remainder*10 + 7

Verdicts: 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):
def main():
    K = int(input())

    crawler = 7
    i = 1

    if (K % 2 ==0) or (K % 5 == 0):
        print(-1)
    else:
        a = [0 for i in range (K+1)]
        a[0] = 7
        for i in range (1, K+1):
            a[i] = (a[i-1]*10 + 7) % K
        for i in a:
            if i == 0:
                print(a.index(i) + 1)
                break
                return 0
    print(-1)

main()

K = int(input())

crawler = 7
i = 1

if (K % 2 ==0) or (K % 5 == 0):
    print(-1)
else:
    a = [0 for i in range (K+1)]
    a[0] = 7
    for i in range (1, K+1):
        a[i] = (a[i-1]*10 + 7) % K
    for i in a:
        if i == 0:
            print(a.index(i) + 1)
            break
print(-1)


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

    crawler = 7
    found = False
    i = 1

    if (K % 2 ==0) or (K % 5 == 0):
        print(-1)
    else:
        a = [0 for i in range (K+1)]
        a[0] = 7
        for i in range (1, K+1):
            a[i] = (a[i-1]*10 + 7) % K
        a[0] = a[0] % K
        for i in a:
            if i == 0:
                print(a.index(i) + 1)
                found = True
                break
        if not found:
            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):
import sys

input = sys.stdin.readline

#k = int(input())
for k in range(1, 100):
    if k == 7 or k == 1:
        print(k, 1)
    elif k % 2 == 0 or k % 5 == 0: print(k, -1)
    else:
        if k % 7 == 0: k = k // 7
        mod = 9*k
        i = 1;
        result = 10;
        while result != 1:
            result = (result * 10) % mod
            i += 1
        print(k, i)

    

        


import sys

input = sys.stdin.readline
k = int(input())
num = 7%k
soln = False
for i in range(1, k+1):
    if num == 0: print(i); soln = 1; break
    num = ((((num%k) * (10%k))%k) + (7%k))%k
if not soln: 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):
def main():
    K = int(input())
    l = [False] * K
    ans = 1
    now = 0
    while True:
        now = now * 10 + 7
        now %= 7
        if now == 0:
            print(ans)
            break

        if l[now]:
            print(-1)
            break
        
        l[now] = True
        ans += 1

if __name__ == '__main__':
    main()

def main():
    K = int(input())
    l = [False] * K
    ans = 1
    now = 0
    while True:
        now = now * 10 + 7
        now %= K
        if now == 0:
            print(ans)
            break

        if l[now]:
            print(-1)
            break
        
        l[now] = True
        ans += 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 math
K = int(input())
seven = int("7" * int(math.log10(K) + 1))
count = 1
while True:
    if seven % K == 0:
        print(count)
        break
    count += 1
    seven = seven * 10 + 7

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

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

Verdicts: 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):
L = int(input())

for K in range(1, L + 1, 2):
    
    ans = -1
    a = 0

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

L = int(input())

for K in range(1, L+1,2):
    
    ans = -1
    a = 0

    if K % 2 == 0:
        ans = -2
    elif K % 5 == 0:
          ans = -5
    else:
        for i in range(0, K):
            a = (10 * a + 7) % K
            #  print("a", a)
            if a == 0:
                ans = i + 1
                break
    print("ans@K=", K, ans)

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

Verdicts: Wrong Answer

Wrong Answer

Accepted