Problem:


Score : 300 points

Problem Statement

Takahashi loves the number 7 and multiples of K.

Where is the first occurrence of a multiple of K in the sequence 7,77,777,\ldots? (Also see Output and Sample Input/Output below.)

If the sequence contains no multiples of K, print -1 instead.

Constraints

1 \leq K \leq 10^6

K is an integer.

Input

Input is given from Standard Input in the following format:

K

Output

Print an integer representing the position of the first occurrence of a multiple of K. (For example, if the first occurrence is the fourth element of the sequence, print 4.)

Sample Input 1

101

Sample Output 1

4

None of 7, 77, and 777 is a multiple of 101, but 7777 is.

Sample Input 2

2

Sample Output 2

-1

All elements in the sequence are odd numbers; there are no multiples of 2.

Sample Input 3

999983

Sample Output 3

999982



Sample input:
101


Sample output:
4

Submission status: Wrong Answer

Solution code:
k = int(input())
start = 7 % k
ans = start
con = 1

if k % 2 == 0 or k % 5 == 0:
  print("No")
  exit()
while True:
  if ans == 0:
    print(con)
    break
  else:
    con += 1
    ans = ans * 10 + 7
    ans = ans % k
    if ans == start:
      print("-1")
      break

Submission status: Wrong Answer

Solution code:
K = int(input())

powlis = [7*pow(10, i, K) for i in range(K)]
for i in range(K-1):
    powlis[i+1] = (powlis[i] + powlis[i+1]) % K



try:
    print(powlis.index(0) + 1)
except:
    print(-1)

Submission status: Wrong Answer

Solution code:
K = int(input())

powlis = [7*pow(10, i, K) for i in range(K)]
for i in range(K-1):
    powlis[i+1] = (powlis[i] + powlis[i+1]) % K

if K==1:
    print(1)
else:
    try:
        print(powlis.index(0) + 1)
    except:
        print(-1)

Submission status: Wrong Answer

Solution code:

K = int(input())

powlis = [7*pow(10, i, K) for i in range(K)]
for i in range(K-1):
    powlis[i+1] = (powlis[i] + powlis[i+1]) % K

try:
    print(powlis.index(0) + 1)
except:
    print(-1)

Submission status: Wrong Answer

Solution code:
K = int(input())

powlis = [pow(10, i, K) for i in range(K)]
for i in range(K-1):
    powlis[i+1] = (powlis[i] + powlis[i+1]) % K

lis = [(7 *powlis[i])%K  for i in range(K) ]

if 0 in lis:
    print(lis.index(0))
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
a = int(input())
b = 7
mod = 7/a 

while mod != 0:
  b = int(str(b) + '7')
  mod = b % a


answer = len(str(b))

  
print(answer)

Submission status: Wrong Answer

Solution code:
K = int(input())
import sys
num = 0
for n in range(7):
  num = num * 10 + 7
  if num % K == 0:
    print(n+1)
    break
else:
  print(-1)

Submission status: Wrong Answer

Solution code:
K = int(input())
import sys
num = 0
for n in range(K):
  num = num * 10 + 7
  if num % K == 0:
    print(n)
    break
else:
  print(-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
K = int(input())

if K % 2 == 0 or K % 5 == 0:
    print(-1)
    exit()
elif K == 7:
    print(1)
    exit()
    
start = j = 7 % K
count = 1

#無限ループ
while True:
    #同じ数のループしているかチェック
    j = 10 * j + 7
    j = j % K
    count += 1
    
    if j == start:
        print(-1)
        exit()
    
    #0の時
    elif j == 0:
        print(count)
        exit()

Submission status: Wrong Answer

Solution code:
K = int(input())
if K % 2 == 0 or K % 5 == 0:
    print(-1)
    exit()
start = j = 7 % K
count = 1
while True:
    j = 10 * j + 7
    j = j % K
    count += 1
    
    if j == 0:
        print(count)
        exit()
    elif j == start:
        print(-1)
        exit()
    else:
        continue

Submission status: Wrong Answer

Solution code:
K = int(input())
if K % 2 == 0 or K % 5 == 0:
    print(-1)
    exit()
start = j = 7 % K
count = 1
for _ in  range(K+1):
    if j != 0:
        j = 10 * j + 7
        j = j % K
        count += 1
    elif j == start:
        print(-1)
        exit()
print(count)

Submission status: Wrong Answer

Solution code:
K = int(input())
if K % 2 == 0:
    print(-1)
    exit()
start = j = 7 % K
count = 1
for _ in  range(K+1):
    if j != 0:
        j = 10 * j + 7
        j = j % K
        count += 1
    elif j == start:
        print(-1)
        exit()
print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
k=int(input())
if (k%2==0 or k%5==0):
    print("-1")
    exit()
i=1
se=7
for _ in range(k):
    se=se*10+7
    i+=1
    se%=k
    if se%k==0:
        print(i)
        exit()

Submission status: Wrong Answer

Solution code:
k=int(input())
if (k%2==0 or k%5==0):
    print("-1")
    exit()
i=1
se=7
for _ in range(k):
    se=se*10+7
    i+=1
    se%=k
    if se%k==0:
        print(i)
        exit()
print('-1')

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution code:
L = int(input())

for K in range(1, L + 1, 2):
    #  print("K = ", K)
    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)

Submission status: Wrong Answer

Solution code:
L = int(input())

for K in range(1, L+1,2):
    #  print("K = ", K)
    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)

Submission status: Wrong Answer

Solution code:
k=int(input())

if k%2==0 or k%5==0:
  print(-1); exit()
  
cnt,num=1,7%k
while 1:
  num*=10
  num+=7
  num%=k
  cnt+=1
  if num==0:
    break
  
print(cnt)

Submission status: Wrong Answer

Solution code:
k=int(input())

if k%2==0 or k%5==0:
  print(-1); exit()
  
cnt,num=1,7
while 1:
  num*=10
  num+=7
  num%=k
  cnt+=1
  if num==0:
    break
  
print(cnt)

Submission status: Wrong Answer

Solution code:
k = int(input())
t = 7
t %= k

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

print(-1)

Submission status: Wrong Answer

Solution code:
k = int(input())
i = 1
s = 7
l = list()
ls = set(l)
lle = len(l)
lsle = len(ls)


while True:
    if k < 7:
        print(-1)
        break
    a = s % k
    if a == 0:
        print(i)
        break
    else:
        l.append(a)
        if lle != lsle:
            print(-1)
            break
        s = s*10 + 7
        i += 1

Submission status: Wrong Answer

Solution code:
k = int(input())
seven = 7
ans = -1

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

print(ans)

Submission status: Wrong Answer

Solution code:
K = int(input())

ans = -1

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

Submission status: Wrong Answer

Solution code:
K = int(input())


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

else:
    ans = 1
    num = 7
    while ans <= K:

        mod = num % K
        if mod == 0:
            break
        else:
            num = mod * 10 + 7
            ans += 1
    
    print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
seven = 7
while N % 2 == 1:
    print(seven)
    if seven % N == 0:
        print(len(str(seven)))
        exit()
    seven = seven * 10 + 7
print(-1)

Submission status: Wrong Answer

Solution code:

ip = int(input())

ans = 7

for i in range(1,8):
    if int(ans) % ip == 0:
        print(i)
        break
    elif i == 8:
        print(int(ans)-1)
    else:
        ans = int(ans) * 10 + 7
        i += 1

Submission status: Wrong Answer

Solution code:
ip = int(input())

ans = 7

for i in range(1,8):
    if int(ans) % ip == 0:
        print(i)
        break
    else:
        ans = int(ans) * 10 + 7
        i += 1

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#C問題　正答
#基本的に～C問題までは「数学的考察が求められない　＝　力技で膨大な数を試せば何とかなる」

#数学的考察をつけるとしたら、「整数Kに対し、余りは0～K-1 のK通り。→K回以内に余りが0にならなければ、永遠にKで割り切れる時は来ない」
#これは「前の項に10倍して7プラスという操作をずっと繰り返してるだけなので、同じ余りが出た途端ループするから

#①前の余りに10倍　②①をmodする　③7を足す　④modする　(※和差積は途中でmod okの性質を利用)
#計算量はO(N)ならN=10^7が上限(これはN<=10^6よりok)

k = int(input())
number = 0
counter = 0
judge = 0

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

Submission status: Wrong Answer

Solution code:
#C問題　正答
#基本的に～C問題までは「数学的考察が求められない　＝　力技で膨大な数を試せば何とかなる」

#数学的考察をつけるとしたら、「整数Kに対し、余りは0～K-1 のK通り。→K回以内に余りが0にならなければ、永遠にKで割り切れる時は来ない」
#これは「前の項に10倍して7プラスという操作をずっと繰り返してるだけなので、同じ余りが出た途端ループするから

k = int(input())
number = 0
counter = 0
judge = 0

for i in range(k):
    #①前の余りに10倍　②①をmodする　③7を足す　④modする　(※和差積は途中でmod okの性質を利用)
    #計算量はO(N)ならN=10^7が上限(これはN<=10^6よりok)
    counter += 1
    number = 7 + 10 * number % k
    if number % k == 0:
        break
if counter == k:
    print(-1)
else:
    print(counter)

Submission status: Wrong Answer

Solution code:
#C問題　正答
#基本的に～C問題までは「数学的考察が求められない　＝　力技で膨大な数を試せば何とかなる」

#数学的考察をつけるとしたら、「整数Kに対し、余りは0～K-1 のK通り。→K回以内に余りが0にならなければ、永遠にKで割り切れる時は来ない」
#これは「前の項に10倍して7プラスという操作をずっと繰り返してるだけなので、同じ余りが出た途端ループするから

k = int(input())
number = 0
counter = 0
judge = 0

for i in range(k):
    #①前の余りに10倍　②①をmodする　③7を足す　④modする　(※和差積は途中でmod okの性質を利用)
    #計算量はO(N)ならN=10^7が上限(これはN<=10^6よりok)
    counter += 1
    number = 7 + 10 * number % k
    if number % k == 0:
        break

print(counter)

Submission status: Wrong Answer

Solution code:
K = int(input())
N = 0

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

print(-1)

Submission status: Wrong Answer

Solution code:
K = int(input())
N = 0

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

print(-1)

Submission status: Wrong Answer

Solution code:
K = int(input())
N = 0

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

Submission status: Wrong Answer

Solution code:
K = int(input())
N = 0

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

Submission status: Wrong Answer

Solution code:
import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mat = lambda x, y, v: [[v]*y for _ in range(x)]
ten = lambda x, y, z, v: [mat(y, z, v) for _ in range(x)]
mod = 1000000007
sys.setrecursionlimit(1000000)

K = ri()

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

Submission status: Wrong Answer

Solution code:
k = int(input())

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

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution code:
N=int(input())
num = 7
i=1
a=[]
prir1=1
while i<N:
    xx=num%N
    if xx==0:
        print(i)
        prir1=0
        break
    num=10*xx+7
    i+=1
if prir1:
    print(-1)

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N=int(input())
num = 7
plus = 70
i=1
a=[]
s = str(N)
array = list(map(int, s))
if(sum(array)%7!=0):
    N*=7
while num%N!=0:
    if num%N in a:
        i=-1
        break
    a.append(num%N)
    num+=plus
    plus*=10
    i+=1
print(i)

Submission status: Wrong Answer

Solution code:
N=int(input())
num = 7
plus = 70
i=1
a=[]

while num%N!=0:
    b=num//N
    print(b*N,num%N)
    if num%N in a:
        i=-1
        break
    a.append(num%N)
    num+=plus
    plus*=10
    i+=1
    if i>N:
        i=-1
        break
print(i)

Submission status: Wrong Answer

Solution code:
N=int(input())
num = 7
plus = 70
i=1
a=[]

while num%N!=0:
    if num%N in a:
        i=-1
        break
    a.append(num%N)
    num+=plus
    plus*=10
    i+=1
    print(num)
    if i>N:
        i=-1
        break
print(i)

Submission status: Wrong Answer

Solution code:
N=int(input())
num = 7
plus = 70
i=1
a=[]
if (N%2==0)or(N%5==0):
    print(-1)
else:
    while num%N!=0:
        if num%N in a:
            i=-1
            break
        a.append(num%N)
        num+=plus
        plus*=10
        i+=1
        print(num)
        if i>N:
            i=-1
            break
    print(i)

Submission status: Wrong Answer

Solution code:
N=int(input())
num = 7
plus = 70
i=1
if (N%2==0)or(N%5==0):
    print(-1)
else:
    s=str(N)
    array = list(map(int, s))
    keta=sum(array)
    while num%N!=0:
        num+=plus
        plus*=10
        i+=1
        print(num)
        if i>N:
            i=-1
            break
    print(i)

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
K=int(input())

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

print(seven)

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

a = [0]*(k+1)
a[0] = 7

for i in range(1, k+1):
    a[i] = (10*a[i-1]+7) % k

for i in range(k+1):
    if a[i] == 0:
        print(i+1)
        sys.exit()
print(-1)

Submission status: Wrong Answer

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

a = [0]*(k+1)
a[0] = 7

for i in range(1, k+1):
    a[i] = (10*a[i-1]+7) % k

for i in range(k):
    if a[i] == 0:
        print(i+1)
        sys.exit()
print(-1)

Submission status: Wrong Answer

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

a = [0]*k
a[0] = 7
cnt = 0

for i in range(1, k):
    a[i] = (10*a[i-1]+7) % k
     


for i in range(k):
    if a[i] == 0:
        print(i+1)
        sys.exit()
print(-1)

Submission status: Wrong Answer

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

a = [0]*k
a[0] = 7
cnt = 0

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

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

Submission status: Wrong Answer

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

a = [0]*k
a[0] = 7
cnt = 0

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

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

Submission status: Wrong Answer

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

a = [0]*k
a[0] = 7
cnt = 0

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

Submission status: Wrong Answer

Solution code:
k = int(input())

if k % 2 == 0 or k % 5 == 0:
    print(-1)
elif k == (1 or 7):
    print(1)
else:
    t = 2
    ex = 77
    for i in range(10 ** 8):
        if ex % k == 0:
            break
        ex = (ex % k) * 10 + 7
        t += 1
    print(t)

Submission status: Wrong Answer

Solution code:
k = int(input())

if k % 2 == 0 or k % 5 == 0:
    print("-1")
elif k == (1 or 7):
    print(1)
else:
    t = 2
    ex = 77
    for i in range(10 ** 8):
        if ex % k == 0:
            break
        ex = (ex % k) * 10 + 7
        t += 1
    print(t)

Submission status: Wrong Answer

Solution code:
k = int(input())

if k % 2 == 0 or k % 5 == 0:
    print("-1")
elif k == (1 or 7):
    print(1)
else:
    t = 2
    ex = 77
    for i in range(10 ** 7):
        if ex % k == 0:
            break
        ex = (ex % k) * 10 + 7
        t += 1
    print(t)

Submission status: Wrong Answer

Solution code:
k=int(input())
d=False
s=7%k

for i in range(k):
  if s==0:
    print(i+1)
    d=True
    break
  s+=7*10**(i+1)%k
    
if d==False:
  print(-1)

Submission status: Wrong Answer

Solution code:
k = int(input())
x = 7
ans = 1
if k%2 == 0 or k%5 ==0:
  ans = -2
else:
  while x%k != 0:
    x *= 10
    x+=7
    if x%k != 0:
      ans +=1

ans +=1
print(ans)

Submission status: Wrong Answer

Solution code:
k=int(input())

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

Submission status: Wrong Answer

Solution code:
k=int(input())

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

Submission status: Wrong Answer

Solution code:
import math

k=int(input())

if k%7==0:
  k=int(k/7)

if k%2==0 or k%5==0:
  print(-1)
else:
  count=0
  for i in range(1,k):
    if math.gcd(i,k)==1:
      count+=1
  
  num=0
  for i in range(1,count):
    num+=(10**i)%k
    num=num%k
    if num==0:
      print(i)
      break

Submission status: Wrong Answer

Solution code:
import math

k=int(input())

if k%7==0:
  k=int(k/7)

if k%2==0 or k%5==0:
  print(-1)
else:
  count=0
  for i in range(1,k):
    if math.gcd(i,k)==1:
      count+=1
  
  num=1
  for i in range(2,count):
    num+=(10**i)%k
    num=num%k
    if num==0:
      print(i)
      break

Submission status: Wrong Answer

Solution code:
k=int(input())
n = 0
num = 1
if k%2==0:
    print("-1")
else:
    while num % k != 0:
        n +=1
        num = int("7"*n)
    print(n)

Submission status: Wrong Answer

Solution code:
import sys

n=input()
test=list(set(n))
#print(test)
if len(test)==1 and test[0]=="7":
    print(len(n))
    sys.exit()
n=int(n)
if n%2 ==0:
    print(-1)
    sys.exit()

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

Submission status: Wrong Answer

Solution code:
import sys

n=int(input())

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

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

Submission status: Wrong Answer

Solution code:
import sys

n=int(input())

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
k = int(input())
a = [None for i in range(10**7) ]

ans = -1
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:
        ans = i
        break

print(ans)

Submission status: Wrong Answer

Solution code:
x= int(input())
i=(len(str(x))-1)
k=9*x
if x%2==0 or x%5==0 :
    print(-1)
else:
    while True:
        if (10**i -1)%(k) ==0:
            break
        else:
            i+=1
    print(i)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#C
# 7,77,777･･･=7*(1,11,111･･･)
# 7*(10^i)=7*(10^i-1)/10-1 = 7*(10^i-1)/9 がkで割れる
# 10^iを(9k,7の倍数だったら9k/7)で割ってあまりが１だったら良い
import sys
k=int(input())
if k%7==0:
    k//=7
k*=9
a=10%k
for i in range(9):
    a=a%k
    if a==1:
        print(i+1)
        sys.exit()
    a*=10
print(-1)

Submission status: Wrong Answer

Solution code:
#C
import sys
k=int(input())
a=7
for i in range(k):
    if a%k==0:
        print(i)
        sys.exit()
    a=a*10+7
print(-1)

Submission status: Wrong Answer

Solution code:
k = int(input())
i = 0
s = 0
ans = -1

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

print(i)

Submission status: Wrong Answer

Solution code:
k = int(input())
i = 0
s = 0
ans = -1

for z in range(k):
    i += 1
    #s = (7 + 10*s) % k
    s = 7 + 10*s
    if s % k != 0:
        s = s % k
    else:
        ans = i

print(i)

Submission status: Wrong Answer

Solution code:
k = int(input())
i = 0
s = 0

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

for z in range(k):
    i += 1
    #s = (7 + 10*s) % k
    s = 7 + 10*s
    if s % k != 0:
        s = s % k
    else:
        break

print(i)

Submission status: Wrong Answer

Solution code:
k = int(input())
i = 0
s = 0

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

for z in range(k):
    i += 1
    s = (7 + 10*s) % k
    if s != 0:
        s = s % k
    else:
        break

print(i)

Submission status: Wrong Answer

Solution code:
k = int(input())
i = 0
s = 0

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

for z in range(k):
    i += 1
    s = (7 + 10*s) % k
    if s != 0:
        s = s % k
    else:
        break

print(i)

Submission status: Wrong Answer

Solution code:
k = int(input())
i = 0
s = 0

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

for z in range(k):
    i += 1
    s = (7 + 10*s) % k
    if s == 0:
        break

print(i)

Submission status: Wrong Answer

Solution code:
K =  int(input())

a = [0]*1000001
ans = -1
a[1] = 7%K

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

Submission status: Wrong Answer

Solution code:
K =  int(input())

a = [0]*1000001
ans = -1
a[1] = 7%K

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

Submission status: Wrong Answer

Solution code:
K = int(input())
i = 0
a = 1
if (K % 2 == 0):
    print(-1)
while (K > 0):
    if (a % K == 0):
        print(len(str(a)))
        break
    else:
        a = a * 10 + 1

Submission status: Wrong Answer

Solution code:
K=int(input())

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

Submission status: Wrong Answer

Solution code:
k = int(input())

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

Submission status: Wrong Answer

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

# 7で割り切れる数かを検証するということは1 ~ kで割ると良い
# ただし、毎回10をかけて7を足していると計算できない範囲まで大きくなるので毎回kで割ったあまりを用いる

k = int(input())

num = 7

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

Submission status: Wrong Answer

Solution code:
# Ai ≡ 0 (mod k) A1 = 7, A2 = 77, A3 = 777

k = int(input())
if k == 7:
    print(1)
    exit()
# よくわからんからAiをmodKにして試してみる
seven = 7
for i in range(1, 10**6 + 10):
    seven = seven * 10 + 7
    seven %= k
    if seven == 0:
        print(i + 1)
        exit()
print(-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())

x = 7
ans = 1

for i in range(3*n):
  if x%n==0:
    break
  ans+=1
  x= x*10 + 7
  x=x%n
    
if ans < n:
  print(ans)
else:
  print(-1)

Submission status: Wrong Answer

Solution code:
n = int(input())

x = 7
ans = 1

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
K = int(input())
 
sevens = 7
count = 0
 
while(sevens % K !=0):
  count += 1
  sevens = sevens * 10 + 7
  if count > K:
    count = -1
    break
    
print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
x=int(input())
if 7%x==0:
    print('No')
elif x>=30:
    print('Yes')
elif x<-40:
    print('No')
else:
    print('No')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

k = int(input())
value = 7

if value % k == 0:
    print(1)

isTrue = 0
for i in range(10**7):
    value = value * 10 + 7
    if value % k == 0:
        isTrue = 1
        break
if isTrue:
    print(len(str(value)))
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
K = int(input())
c = "-1"
for i in range(1,2000):
    if int("7"*i) % K == 0:
        c = i
        break
print(c)

Submission status: Wrong Answer

Solution code:
K = int(input())
c = "-1"
for i in range(1,100):
    if int("7"*i) % K == 0:
        c = i
        break
print(c)

Submission status: Wrong Answer

Solution code:
K = int(input())

ans = 1
num = 0
seven = 7

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

Submission status: Wrong Answer

Solution code:
K = int(input())

ans = 1
num = 0
seven = 7

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

Submission status: Wrong Answer

Solution code:
K = int(input())
i = 1
j = 7

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

Submission status: Wrong Answer

Solution code:
K=int(input())

x=7%K
modlist=[7]
i=1
flag=0
while(x not in modlist):
  if x==0:
    print(i)
    flag=1
    break
  modlist.append(x)
  x=(10*x+7)%K
  i+=1

if flag==0:
  print(-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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