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:
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  k=I()
  st=7
  for i in range(1,1000001):
    st+=7*pow(10,i,k)
    st%=k
    if st==0:
      return i+1

  return -1

# main()
print(main())

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N=int(input())
if N%2==0:
  print("-1")
else:
  M=7
  for i in range(1,20):
    M="7"*i
    S=int(M)
    if S%N==0:
      print(i)
      exit()

Submission status: Wrong Answer

Solution code:
K = int(input())

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

Submission status: Wrong Answer

Solution code:
from itertools import count

K = int(input())
f = lambda x: (x*10+1)%K

a = f(1)
b = f(f(1))


for t in count(2):
    if a == 0:
        print(t)
        break
    if a == b:
        print(-1)
        break
    a = f(a)
    b = f(f(b))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
k = int(input())
#a,b = map(int,input().split())
#a_L = list(map(int,input().split()))

sevn = "7"
i = 1
for i in range(10**6+1):
    tmp = int(sevn)
    if tmp%k==0:
        print(i)
        exit()
    sevn += "7"
    #i += 1

print(-1)

Submission status: Wrong Answer

Solution code:
k = int(input())
temp = 0
M = 10**5
for i in range(2*10**6):
    temp *= 10
    temp += 1
    temp %= k
    if temp == 0:
        print(i+1)
        exit()
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
K=int(input())

ans=1
MOD=set()

cur=7
while True:
    if cur==0:
        print(ans)
        exit()
    else:
        r=cur%K
        if r in MOD:
            print(-1)
            exit()
        else:
            MOD.add(r)
        cur=(cur*10+7)%K
        ans+=1

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
k = int(input())
temp = 0
M = 10**5
for i in range(10**6+50):
    temp *= 10
    temp += 1
    temp %= k
    if temp == 0:
        print(i+1)
        exit()
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
n = int(input())
ctr = 1
if n % 2 == 0:
    print(-1)
else:

    val = 7
    while (val % n != 0):
        val = val*10+7
        ctr += 1
print(ctr)

Submission status: Wrong Answer

Solution code:
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
R=list()
N=int(input())
L=factorization(N)
if len(L)==2 and  L[0][0]==2 and L[1][0]==5:
  print(-1)
else:
  r=1
  for i in range(1, N):
    R.append(r)
    r=(r*10)%N
  print(len(set(R)))

Submission status: Wrong Answer

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

power = 1
SUM = 0

for i in range(1, 10 ** 6):
    SUM += power
    if SUM % K == 0:
        print(i)
        sys.exit()
    power *= 10
    power %= K

print(-1)

Submission status: Wrong Answer

Solution code:
import math
K = int(input())
if K == 7 or K == 1:
  print(1)
elif math.gcd(K,10) != 1:
  print(-1)
else:
  cnt = 1
  res = 10
  while True:
    cnt += 1
    res *= 10
    res %= (9 * K)
    if res == 1:
      break
  print(cnt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
import heapq
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache

#############
# Constants #
#############

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

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()

#####Shorten#####
def DD(arg): return defaultdict(arg)

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n): return kaijo_memo[n]
  if(len(kaijo_memo) == 0): kaijo_memo.append(1)
  while(len(kaijo_memo) <= n): kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n): return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0): gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n): gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if n == r: return 1
  if n < r or r < 0: return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1: arr.append([temp, 1])
  if arr==[]: arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####MakePrimes######
def make_primes(N):
  max = int(math.sqrt(N))
  seachList = [i for i in range(2,N+1)]
  primeNum = []
  while seachList[0] <= max:
    primeNum.append(seachList[0])
    tmp = seachList[0]
    seachList = [i for i in seachList if i % tmp != 0]
  primeNum.extend(seachList)
  return primeNum

#####GCD#####
def gcd(a, b):
    while b: a, b = b, a % b
    return a

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n-1
    count += 1
  return count

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n: return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i-1])*n**i for i in range(len(str(X))))

def base_10_to_n_without_0(X, n):
  X -= 1
  if X//n: return base_10_to_n_without_0(X//n, n)+[X%n]
  return [X%n]

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############

K = I()

now = 7%K
count = 1

while now:
  now *= 10
  now += 7
  now %= K
  count += 1
  if count >= K:
    print(-1)
    exit()
  
print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().rstrip().split()
def S(): return sys.stdin.readline().rstrip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 998244353


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

Submission status: Wrong Answer

Solution code:
a = int(input(""))
print(777777 / a)

Submission status: Wrong Answer

Solution code:
K = int(input())

cur = 7
index = 1
for _ in range(2 * K):
    if cur == 0:
        break
    index += 1
    cur *= 10
    cur += 7
    cur %= K

if index > K:
    print(-1)
else:
    print(index)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

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

Submission status: Time Limit Exceeded

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

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: Time Limit Exceeded

Solution code:
k = int(input())
con = 1
lis = []
ans = 7

while True:
  ans = ans % k
  if ans == 0:
    print(con)
    break
  else:
    if ans in lis:
      print("-1")
      break
    else:
      lis.append(ans)
      ans = ans * 10 + 7
      con += 1

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
K = int(input())
start = j = 7 % K
count = 1
while j != 0:
    j = 10 * j + 7
    j = j % K
    count += 1
    if j == start:
        print(-1)
        exit()
print(count)

Submission status: Time Limit Exceeded

Solution code:
import sys
read = sys.stdin.read
#readlines = sys.stdin.readlines
from collections import defaultdict
def main():
    k = int(input())
    if k % 2 == 0:
        print(-1)
        sys.exit()
    rems = defaultdict(int)
    n = 7
    next_digit = 70
    r = 1
    while True:
        rem = n % k
        if rem == 0:
            print(r)
            sys.exit()
        elif rems[rem]:
            print(-1)
            sys.exit()
        else:
            rems[rem] = 1
            n += next_digit
            next_digit *= 10
            r += 1
if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
k=int(input())

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

cnt=num=0
while 1:
  num+=7*pow(10,cnt,k)
  num%=k
  cnt+=1
  if num==0:
    break
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
k=int(input())

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

cnt=num=0
while 1:
  num+=7*pow(10,cnt,k)
  cnt+=1
  if num%k==0:
    break
print(cnt)

Submission status: Time Limit Exceeded

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

if k % 2 == 0:
    ans = -1
elif k == 1 or k == 7:
    ans = 1
else:
    while seven % k != 0:
        seven = seven * 10 + 7
        ans += 1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
k = int(input())
count = 1
sev = 7

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

        if sev%k==0 :
            print(count)
            break

        count += 1
        sev = sev*10 + 7

Submission status: Time Limit Exceeded

Solution code:
k = int(input())
num = ''
li = []

is_there = False
while not is_there:
    num = int(str(num)+'7')
    li.append(num)
    if num % k == 0:
        print(len(li))
        is_there = True

Submission status: Time Limit Exceeded

Solution code:
# ABC174 C

K=int(input())

res=1
r=7
while 1:
    if not r%K:
        break
    r=(10*r+7)%K
    res+=1
print(res)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
k = int(input())
n = 7
cnt = 1
while 1:
    if n % k == 0:
        print(cnt)
        exit()
    elif n % k != 0 and cnt < k +1:
        cnt += 1
        n = (n*10 + 7) % k
    elif (n % k != 0 and cnt > k + 1):
        print(-1)
        exit()

Submission status: Time Limit Exceeded

Solution code:
k = int(input())
n = 7
cnt = 1
while 1:
    if n % k == 0:
        print(cnt)
        exit()
    elif n % k != 0 and cnt <1000000:
        cnt += 1
        n = (n*10 + 7) % k
    elif n % k != 0 and cnt > 1000000:
        print(-1)
        exit()

Submission status: Time Limit Exceeded

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

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

print(-1)

Submission status: Time Limit Exceeded

Solution code:
import sys
#import time
from collections import deque, Counter, defaultdict
#from fractions import gcd
import bisect
import heapq
#import math
import itertools
import numpy as np
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
inf = 10**18
MOD = 1000000007
ri = lambda : int(input())
rs = lambda : input().strip()
rl = lambda : list(map(int, input().split()))

k = ri()
reses=[]
cnt = 1
tmp = 7
while True:
    res = tmp % k
    if res==0:
        print(cnt)
        break
        sys.exit()
    else:
        if res not in reses:
            reses.append(res)
        else:
            print("-1")
            break
            sys.exit()
    tmp = res * 10 + 7
    cnt += 1

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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
    if i>N:
        i=-1
        break
print(i)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
num = 7
plus = 70
i=1
if (N%2==0)or(N%5==0):
    print(-1)
else:
    while num%N!=0:
        num+=plus
        plus*=10
        i+=1
    print(i)

Submission status: Time Limit Exceeded

Solution code:
line = int(input())
number =7
cnt1 =0
cnt2 =1
if line %2 ==0 or line%5 ==0:
  print(-1)
  cnt1 +=2

while cnt1 ==0:
  if number%line !=0:
    number += 7*10**cnt2
    cnt2 +=1
  else:
    cnt1 +=1
if cnt1 ==1:
  print(cnt2)

Submission status: Time Limit Exceeded

Solution code:
K=int(input())
if K%2==0:
	print(-1)
else:
	seven=0
	m=1
	count=0
	while m!=0:
		seven=seven*10+7
		m=seven % K
		count+=1

	print(count)

Submission status: Time Limit Exceeded

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+1
      break

print(ans)

Submission status: Time Limit Exceeded

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 (k):
    ans +=1
    x = x*10+7
    if x%k == 0:
      break


print(ans)

Submission status: Time Limit Exceeded

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

print(ans)

Submission status: Time Limit Exceeded

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
k=int(input())

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

Submission status: Time Limit Exceeded

Solution code:
K = int(input())
#a1= 7 mod K
#a2= a1*10+7 mod K
#a3= a2*10+7 mod K
a = 0
count = -1
for i in range(K):
    a = (7 + a*10)
    if a % K== 0:
        count=i+1
        break
print(count)

Submission status: Time Limit Exceeded

Solution code:
k=int(input())
n = 0
num = 1
if k%2==0:
    print("-1")
elif k == 1:
    print("1")

else:
    while num % k != 0:
        n +=1
        num = int("7"*n)
    print(n)

Submission status: Time Limit Exceeded

Solution code:
K = int(input())

num = 7

if(7 % K == 0):
    print(1)
    exit()

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

print(-1)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
k = int(input())

maxV = (10**6)**2

i = 0
sevens = 0
while True:
    sevens = sevens * 10 + 7
    sevens = sevens % k
    i+=1
    if sevens % k == 0:
        print(i)
        exit()

print(-1)

Submission status: Time Limit Exceeded

Solution code:
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):
    if a % L == 1:
      print(i + 1)
      check = True
      break
    a *= 10
  if not check:
    print(-1)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
K = int(input())
nana = 7
kou = 1
if K % 2 == 0:
    print(-1)
else:
    while True:
        if nana % K == 0:
            break
        nana = (nana * 10 + 7) % K
        kou+=1
    print(kou)

Submission status: Time Limit Exceeded

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(k*9):
    a=a%k
    if a==1:
        print(i+1)
        sys.exit()
    a*=10
print(-1)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
K = int(input())
nana = "7"
kou = 1
if K % 2 == 0:
    print(-1)
else:
    while True:
        if int(nana) % K == 0:
            break
        nana += '7'
        kou+=1
    print(kou)

Submission status: Time Limit Exceeded

Solution code:
def main():
    n = int(input())
    mod = 0
    pow10 = 1
    for i in range(20*n):
        mod = (mod+7*pow10) % n
        if mod == 0:
            print(i+1)
            return
        pow10 = pow10*10 % n
    print(-1)


main()

Submission status: Time Limit Exceeded

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

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

while True:
    i += 1
    s = 7 + 10*s
    if s % k == 0:
        break

print(i)

Submission status: Time Limit Exceeded

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

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

while True:
    i += 1
    s = (7 + 10*s) % k
    if s == 0:
        break

print(i)

Submission status: Time Limit Exceeded

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

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

while True:
    i += 1
    s = (7 + 10*s) % k
    if s == 0:
        print(i)
        exit()

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
# Kの入力
k = int(input())

# 出力
ans = 1
for i in range(k):
    if int("7"*(i+1)) % k == 0:
        break
    else:
        ans += 1
        if ans == k+1:
            ans = -1

print(ans)

Submission status: Time Limit Exceeded

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

if K % 5 == 0 or K % 2 == 0:
    i = -1

while True:
    if i == -1:
        break
    N = "7" * i
    N = int(N)
    if N % K != 0:
        i += 1
        continue
    else:
        break
print(i)

Submission status: Time Limit Exceeded

Solution code:
from time import time
start = time()
n = int(input())
status = 0

while time()-start < 1:
  if status == 1:
    break
  sevens = []
  while True:
    sevens.append('7')
    seven_num = int(''.join(sevens))
    if seven_num % n == 0:
      status += 1
      break

if status == 1:
  print(len(sevens))
else:
  print(-1)

Submission status: Time Limit Exceeded

Solution code:
K=int(input())
seven=7
count=1
if K%2==0:
   print(-1)
else:
   
 while True:
   if seven%K==0:
    print(count)
    break
   else:
    seven=seven*10+7
    count+=1
   continue

Submission status: Time Limit Exceeded

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

while True:
   if seven%K==0:
    print(count)
    break
   else:
    seven=seven*10+7
    count+=1
   continue

Submission status: Time Limit Exceeded

Solution code:
# ABC174C
k = int(input())
num = str("")
res = []
cnt = 0
mod = 0

while(1):
    cnt += 1
    num = "7" * cnt
    num = int(num)
    mod = num % k
    if mod == 0:
        print(cnt)
        break
    else:
        if mod in res:
            print(-1)
            break
        else:
            res.append(mod)

Submission status: Time Limit Exceeded

Solution code:
K = int(input())
 
def seven(s):
   t = ''
   for i in range(s):
      t = t + '7'
   return int(t)
 
result = -1
 
if not str(K)[-1] in ['0', '2', '4', '5', '6', '8']:
   count = 1
   while True:
      if seven(count) % K == 0:
         result = count
         break
      count = count + 1
 
print(result)

Submission status: Time Limit Exceeded

Solution code:
k = int(input())
seven = '7'
sevens ='7'
cnt = 1

if k % 2 ==0:
    print(-1)
else:
    while len(sevens) < 10**6:
        if int(sevens) % k ==0:
            print(cnt)
            break
        else:
            sevens += seven
            cnt += 1

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
K = int(input())



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

Submission status: Time Limit Exceeded

Solution code:
k = int(input())
s = '7'
cnt = 1
while 1:
  if int(s) % k == 0:
    break
  else:
    s += '7'
    cnt += 1
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
k = int(input())
s = '7'
cnt = 1
if k%2==0 or k%5==0:
    print(-1)
    exit()

while int(s)%k!=0:
    s += '7'
    cnt += 1
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
K = int(input())

cnt_dig = 1
sev = 7
if K % 2 == 0:
    print(-1)
else:
    while 1 :
        if sev % K == 0:
            print(cnt_dig)
            break
        else:
            sev *= 10
            sev += 7
            cnt_dig += 1

Submission status: Time Limit Exceeded

Solution code:
K = int(input())
 
sevens = 7 % K
count = 1
 
while(sevens % K !=0):
  # 計算桁を減らすために(mod K)で7, 77, 777,,,を計算する
  sevens = sevens * (10 % K) + (7 % K)
  count += 1
  if count > K:
    count = -1
    break
    
print(count)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
k = int(input())
start = 7
def judge(l, x):
  if l % x == 0:
    return True
  else:
    return False

def long7(i):
  x = "7"*i
  return int(x)


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

cnt = len(str(k)) -1
          

          
for i in range(len(str(k)), 10000000):
  l = long7(i)
  cnt += 1
  if judge(l, k) == True:
    print(cnt)
    exit()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
k=int(input())
num=7
amari=[]
while True:
    if num%k==0:
        print(str(num).count("7"))
        break
    elif str(num).count("7")==num:
        print("-1")
        break
    else:
        if num%k in amari:
            print("-1")
            break
        else:
            amari.append(num%k)
            num=num*10+7

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
num = int(input())
sevens = 7
cnt = 1

if num%2 == 0:
	print(-1)
	exit()
else:
    while sevens%num != 0:
    	sevens = sevens+7*pow(10,cnt) ##桁をひとつ更新
    	cnt+=1

print(cnt)

Submission status: Time Limit Exceeded

Solution code:
K=int(input())

x=7%K
#modlist=[]
modlist={i:0 for i in range(K) }
i=1
flag=0
while(modlist[x]==0):
  if x==0:
    print(i)
    flag=1
    break
  #modlist.append(x)
  modlist[x]==1
  x=(10*x+7)%K
  #if i==99983:
    #print(x)
  i+=1


if flag==0:
  print(-1)

Submission status: Time Limit Exceeded

Solution code:
K=int(input())

x=7%K
modlist=[]
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: Time Limit Exceeded

Solution code:
k = int(input())
val = 7
count = 1
if(k % 2 == 0 or k % 5 == 0):
	print(-1)
	exit()
while(True):
	if(val % k == 0):
		break
	if(count >= 100000):
		print(-1)
		exit()
	count += 1
	val = val * 10 + 7
print(count)

Submission status: Time Limit Exceeded

Solution code:
k = int(input())
val = 7
count = 1
while(True):
	if(val % k == 0):
		break
	if(count >= 100000):
		print(-1)
		exit()
	count += 1
	val = val * 10 + 7
print(count)

Submission status: Time Limit Exceeded

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