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

Solution code:
K = int(input())

nana = 7
count = 1

mod = 7 % K 

past = [mod]

while mod != 0:
  mod = (mod * 10 + 7) % K
  if mod in past:
    break
  past.append(mod)
  count += 1
  
if mod == 0:
  print(count)
else:
  print(-1)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
if n%2==0:
    print(-1)
else:
    c=1
    k=7
    while 1:
        if k%n==0:
            break
        if c>n:
            c=-1
            break
        k=int(str(k)+'7')
        c+=1
        #print(k)
    print(c)

Submission status: Time Limit Exceeded

Solution code:
k = int(input())



if k % 2 != 0 and k % 5 != 0:
    if k % 7 == 0:
        l = 9 * k // 7
    else:
        l = 9 * k
    for i in range(1,k + 3):
        if (10 ** i) % l == 1:
            print(i)
            break

else:
    print(-1)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    k = int(input())
    ans = 0

    if k % 2 == 0 or k % 5 == 0:
        print(-1)
    else:
        a = 7
        while 1:
            if a % k == 0:
                print(len(str(a)))
                break
            else:
                a = a * 10 + 7

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
k=int(input())
a=[]
count=1
if k%2==0:
    print(-1)
else:
    ai=7%k
    while 1:
        if ai==0:
            print(count)
            break
        elif ai in a:
            print(-1)
            break
        else:
            a.append(ai)
            ai=(ai*10+7)%k
            count+=1

Submission status: Time Limit Exceeded

Solution code:
import math
k = int(input())
count = 1
seven = 7
if k%2 == 0 or k%5 == 0:
    print(-1)
else:
    while True:
        if(seven%k==0):
            print(count)
            break
        else:
            seven += 7* (10**count)
            count+=1

Submission status: Time Limit Exceeded

Solution code:
K=int(input())
if K%2==0:
    print(-1)
else:
    if K%7==0:
        L=9*K//7
    else:
        L=9*K
    i=1
    rest=(10**i)%L
    while True:
        if rest==1:
            print(i)
            exit()
        else:
            rest=(rest*10)%L
            i+=1

Submission status: Time Limit Exceeded

Solution code:
import sys

k=int(input())
if k%2==0:
  print(-1)
  sys.exit(0)
c=1
m=7%k
while 1:
  if m==0:
    print(c)
    sys.exit(0)
  m=m*10+7
  m%=k
  c+=1

Submission status: Time Limit Exceeded

Solution code:
K = int(input())

hit = False
if int(K) % 2 == 0:
    print("-1")
else:
    seven_number = 0
    mods = []
    count = 0
    while True:
        if count == K:
            print("-1")
            break
        seven_number = seven_number * 10 + 7
        mod = seven_number % K
        if mod == 0:
            print(len(str(seven_number)))
            hit = True
            break
        if mod in mods:
            print("-1")
            break
        mods.append(mod)
        count += 1

Submission status: Time Limit Exceeded

Solution code:
k = int(input())
if k % 2 == 0:
    print(-1)
    exit()
elif k == 1 or k == 7:
    print(1)
    exit()
sv = 7
ans = 1
while True:
    if sv == 0:
        break
    sv = (sv * 10 + 7) % k
    ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

s = input()
K = int(s)

if ((K & 1 == 0) or (int(s[-1]) % 5 == 0)):
  print(-1)

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

i = 1
r = 10
while True:
  r = r % L
  if r == 1:
    print(i)
    break
  r *= 10
  i += 1

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3

def main():
    K = int(input())
    if K % 7 == 0:
        L = 9 * K / 7
    else:
        L = 9 * K
    if L == 2 or L == 5:
        ans = -1
    else:
        i = 1
        tmp = 10
        while True:
            tmp %= L
            if tmp == 1:
                ans = i
                break
            i += 1
            tmp *= 10

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3

def main():
    K = int(input())
    if K % 7 == 0:
        L = 9 * K / 7
    else:
        L = 9 * K
    if K == 2 or K == 5:
        ans = -1
    else:
        i = 1
        tmp = 10
        while True:
            tmp %= L
            if tmp == 1:
                ans = i
                break
            i += 1
            tmp *= 10

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

result = -1
num = 7
K = I()

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

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

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3

def main():
    K = int(input())
    if K == 2 or K == 5:
        ans = -1
    else:
        if K % 7 == 0:
            L = 9 * K / 7
        else:
            L = 9 * K
        i = 1
        tmp = 10
        while True:
            tmp %= L
            if tmp == 1:
                ans = i
                break
            i += 1
            tmp *= 10

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
k = int(input())
if k % 7 != 0:
  l = 9 * k
else:
  l = int(9 * k / 7)

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

count = 1
n = 10
while True:
  if n % l == 1:
    break
  n = (n % l) * 10
  count += 1
print(count)

Submission status: Time Limit Exceeded

Solution code:
param_a = int(input())

if param_a%2==0:
    print(-1)
    
elif param_a%5==0:
    print(-1)

else:
    for i in range(1000000):
        param_str = '7'*(i+1)
        param_int = int(param_str)
        
        if param_int % param_a == 0:
            param_answer = i+1
            break
     
    try:
        print(param_answer)
    except:
        print(-1)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
k=int(input())
if k%2==0:
    print(-1)
    exit()
count=1
a=0
while True:
    a=(a*10+7)%k
    if a==0:
        print(count)
        exit()
    count+=1

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
k = int(input())

if k%7==0:
    l = 9 * k / 7
else:
    l = 9 * k

i = 0
ans = 0
a = 10

while i<l+5:
    ans += 1
    if a%l==1:
        print(ans)
        exit()
    else:
        a = a % l
        a *= 10
    i += 1

print(-1)

Submission status: Time Limit Exceeded

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

K = INT()

tmp = 7
ans = 1
p = 1
mo = tmp % K
checked = [0] *  (10 ** 6 + 1)
checked[mo] = 1

while mo != 0:
    mo = mo + 7 * pow(10, p, K)
    mo %= K
    p += 1
    if checked[mo]:
        # 0には一生辿り着かない
        print(-1)
        break
    checked[mo] = 1
else:
    print(p)

Submission status: Time Limit Exceeded

Solution code:
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+1)
        break
    else:
        i += 1
        suretu *= 10
        suretu += 7

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
K = int(input())
ans = 1
sev = 7

while sev%K:
  ans+=1
  sev=(10*sev+7)%K
else:
  print(ans)
  exit()

print(-1)

Submission status: Time Limit Exceeded

Solution code:
k = int(input())
a=7
i=1
if k%5==0 or k%2==0:
  print(-1)
  exit()
while True:
  if a%k ==0:
    print(i)
    exit()
  i+=1
  a = a + 7*10**(i-1)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
k = int(input())

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

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


print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
k=int(input())

x=1
c=7

if k%2==0:
    print('-1')
for i in range(k+1):
    if c%k==0:
        print(x)
        break
    else:
        c=str(c)
        c=int(c+'7')
        x+=1

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
k = int(input())
a = []
if(k%2 == 0):
  print(-1)
else:
    while(1):
        a.append(7)
        b = ''.join(map(str,a))
        b = int(b)
        #print(b)
        if(b%k == 0):
            break
    print(len(a))

Submission status: Time Limit Exceeded

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

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

    x = 7
    first = True
    flag = False
    while True:
        if(first):
            x = 7
            first = False
        else:
            x = x * 10 + 7
        
        if(x % K == 0):
            print(len(str(x)))
            flag = True
            break
    
    if(flag != True):
        print(-1)


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
k = int(input())

n = 0
ans = 1
f = True

for i in range(k):
  n = n*10 + 7
  if n % k == 0:
    print(ans)
    f = False
    break
  ans+=1

if f:
  print(-1)

Submission status: Time Limit Exceeded

Solution code:
k = int(input())
if k%2==0 or k%5==0:
    print('-1')
else:
    from itertools import accumulate
    ac = list(accumulate([7*pow(10, i, k)%k for i in range(999983)]))
    for idx, a in enumerate(ac):
        if a%k == 0:
            print(idx+1)
            break
    else:
        print('-1')

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
k = int(input())

#-1についてはまだ実装してない
nana = "7"
for i in range(10**6):
    if int(nana) % k == 0:
        print(i+1)
        break
    else:
        nana += "7"

Submission status: Time Limit Exceeded

Solution code:
k=int(input())
if k%2==0:
    print(-1)
    exit()
count=1
while True:
    if int('7'*count)%k==0:
        print(count)
        break
    count+=1

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

num = 0

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

Submission status: Time Limit Exceeded

Solution code:
K = int(input())

if K % 2 == 0 or K % 5 == 0:
    print(-1)
else:
    kuriagari = 0
    ans = []
    n = 0
    r = 0
    flag = True
    while flag:
        for i in range(0,10):
            if str(K * (i*(10**r)+n))[-(r+1)] == "7":
                n = (i*(10**r)+n)
                r += 1
                if all([s == "7" for s in str(n*K)]):
                    print(len(str(n*K)))
                    flag = False
                    break

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
K = int(input())
i = 1
N = 0
if K%2==0:
    print(-1)
    exit()
while(i<1000000):
    N += 7*(10**(i-1))
    if N%K == 0:
        print(i)
        exit()
    i += 1
print(-1)

Submission status: Time Limit Exceeded

Solution code:
#import sys
MOD = 10 ** 9 + 7
INFI = 10**10
#input = sys.stdin.readline
import math
from collections import deque
import itertools
import heapq
#import bisect
from fractions import Fraction
import copy
from functools import lru_cache
from collections import defaultdict
import pprint

#oo=list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
# ko=list("abcdefghijklmnopqrstuvwxyz")

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]

def ret(a):
    c=[None]*(len(a)-1)
    if len(a)==1:
        return a[0]
    elif len(a)==0:
        return 0
    for i in range(1,len(a)):
        c[i-1]=abs(a[i]-a[i-1])
    return ret(c)

def soinsubunkai(n):
    a = []
    i = 1
    while i*i <= n:
        if n % i == 0 and i!=1:
            a.append(i)
            n=n//i

        if n% i !=0 or i==1:
            i += 1
    nokori=[n]
    return a + nokori

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

def main():
    #l,r,d=map(int,input().split())
    k=int(input())
    a=7
    i=1
    amari=0
    while True:
        temp=a%k
        if temp==0:
            break
        else:
            a=7+a*10
            i+=1
        if i>k:
            i=-1
            break
    print(i)



if __name__ == "__main__":

    main()

Submission status: Time Limit Exceeded

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

result = -1
num = 7
K = I()

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

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

Submission status: Time Limit Exceeded

Solution code:
k = int(input())
a = []
if(k%2 == 0):
  print(-1)
else:
    while(1):
        a.append(7)
        b = ''.join(map(str,a))
        b = int(b)
        #print(b)
        if(b%k == 0):
            break
    print(len(a))

Submission status: Time Limit Exceeded

Solution code:
K = input()
l = len(K)

counter = -1
if int(K[l-1]) % 2 :
    if int(K[l-1]) % 5 :
        k = int(K)
        a = 7
        counter =1 
        while True :
            if a % k == 0 :
                break
            a = 7+10*a
            counter += 1

print(counter)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

result = -1
num = 7
K = I()

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

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

Submission status: Time Limit Exceeded

Solution code:
K = int(input())

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

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

print(-1)

Submission status: Time Limit Exceeded

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

x = 7 % K
i = 1
while True:
    if x == 0:
        print(i)
        exit()
    y = (x * 10 + 7) % K
    if x == y:
        print(-1)
        exit()
    x = y
    i += 1

Submission status: Time Limit Exceeded

Solution code:
K = int(input())

n = 7
i = 1
ans = -1

while i <= K:
    if n%K == 0:
        ans = i
        break
    n = n*10 + 7
    i += 1

if ans != -1:
    print(ans)    
else:
    print(-1)

Submission status: Time Limit Exceeded

Solution code:
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())

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

Submission status: Time Limit Exceeded

Solution code:
import sys
K = int(input())
target = 7
for i in range(1,100000):
  if target %  K == 0:
    print(i)
    sys.exit()
  else:
    target *= 10
    target += 7
  
print("-1")

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())

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

Submission status: Time Limit Exceeded

Solution code:
K = int(input())
ans = -1
if K in [2,5]:
    pass
else:
    num = 7
    ans = 0
    while True:
        ans += 1
        if num % K == 0:
            break
        else:
            num = (num * 10 + 7)%K
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
K = int(input())

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

Submission status: Time Limit Exceeded

Solution code:
import sys

def input():
    return sys.stdin.readline().strip()

def main():

    K = int(input())

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

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

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
#!python3.8
# -*- coding: utf-8 -*-
# abc174/abc174_c
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    K = i2n()

    #while K % 7 == 0:
    #    K = K // 7
    x = 10 % K
    a = 0
    for i in range(1, K + 10):
        a = a * 10 + 7
        if a % K == 0:
            print(i)
            return
    else:
        print('-1')
    return

main()

Submission status: Time Limit Exceeded

Solution code:
k = int(input())

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

Submission status: Time Limit Exceeded

Solution code:
K=int(input())
if K%2==0:
    print('-1')
    exit()
a=0
i=1
while True:
    a=(a*10+7)%K
    if a==0:
        print(i)
        break
    i+=1

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
K = int(input())

ans = 1
a = 7
i = K
while K > 0:
    m = a % K
    if m == 0:
        print(ans)
        break
    else:
        ans += 1
        a = m * 10 + 7
        i -= 1
if m != 0:
    print(-1)

Submission status: Time Limit Exceeded

Solution code:
K = int(input())

t = 7
ans = 1

for _ in range(K):
    if t % K == 0:
        print(ans)
        exit(0)
    else:
        t = t * 10 + 7
        ans += 1

print(-1)

Submission status: Time Limit Exceeded

Solution code:
k = int(input())
n = 10**6
a = "7"

for i in range(n):

    if int(a) % k == 0:
        print(i+1)
        break

    a += "7"
else:
    print("-1")

Submission status: Time Limit Exceeded

Solution code:
K = int(input())
l = len(str(K))
x = '7'
while True:
    X = x * l
    l += 1
    if K % 2 == 0:
        print("-1")
        exit()
    elif int(X) % K == 0:
        break
print(len(str(X)))

Submission status: Time Limit Exceeded

Solution code:

def solve():
	n=input()
	s='7'*len(n)
	flag=1
	i=len(n)
	if(int(n)%2==0 and int(n)%5==0):
		print(-1)
		return
	while(flag):
		if(int(s)%int(n)==0):
			flag=0
		else:
			i+=1
			s='7'*i
	print(len(s))
if __name__ == "__main__":
	#code goes below
	# for _ in range(int(input())):
	solve()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
if __name__ == '__main__':
    k = int(input())

    if k % 2 == 0 or k % 2 == 5:
        print('-1')
    else:
        num = '7'
        count = 1
        while not int(num) % k == 0:
            count += 1
            num += '7'
        print(len(num))

Submission status: Time Limit Exceeded

Solution code:
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush,heapify
from math import ceil, floor, sqrt
from copy import deepcopy


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

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

    num = "7"
    ans = 1
    while(int(num)%k != 0):
        num += "7"
        ans += 1

    print(ans)

if __name__ == '__main__':
	main()

Submission status: Time Limit Exceeded

Solution code:
k = int(input())

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
# Problem C - Repsept
# input
K = int(input())

# initialization
seven = 7
ans = 1

# count
if K%2==0 and K%5==0:
    ans = -1
elif K==1:
    ans = 1
else:
    tmp_list = [0]*(10**6+1)
    while not seven%K==0: # 割り切れない限り
        seven = seven*10 + 7
        seven = seven % K
        ans += 1


# output
print(ans)

Submission status: Time Limit Exceeded

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

    if K % 2 == 0:
        return -1
    elif K % 5 == 0:
        return -1
    an = 7
    counter = 1

    while True:
        if an % K == 0:
            return counter

        an = an * 10 + 7
        counter = counter + 1

if __name__ == "__main__":
    answer = main()
    print(answer)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
K = int(input())
hist = set()

INF = 10**8

w = 0
for i in range(INF):
  w += 7 * pow(10,i,K)
  w %= K
  if w == 0:
    print(i+1)
    break
  else:
    if w in hist:
      print(-1)
      break
    else:
      hist.add(w)
      
#print(hist)

Submission status: Time Limit Exceeded

Solution code:
from collections import deque

K = int(input())
s = deque([7])

if K % 2 == 0:
	print(-1)
else:
	while int("".join(map(str, s))) % K != 0:
		s.append(7)
	if True:
		print(len(s))

Submission status: Time Limit Exceeded

Solution code:
K = int(input().rstrip())

if K % 2 == 0:
    print(-1)
elif K % 10 == 5:
    print(-1)
else:
    n = 1
    while True:
        val = 7 * sum([ 10**i for i in range(n) ])
        if val % K == 0:
            break
        n += 1
    print(n)

Submission status: Time Limit Exceeded

Solution code:
K = int(input())

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

Submission status: Time Limit Exceeded

Solution code:
k = int(input())
n = 0

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

print(-1)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
import sys


def solve(K: int):
    last_digit = int(str(K)[-1])

    if last_digit in [2,4,6,8,0]:
        print(-1)
        return

    svs = '7'
    L=1
    while int(svs) % K != 0:
        svs += '7'
        L += 1

    print(L)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    solve(K)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
k = int(input())

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

n = 0

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

print(-1)

Submission status: Time Limit Exceeded

Solution code:
k = int(input())

if str(k)[-1] not in ["1","3","7","9"]:
    print(-1)
    exit()

tmp = "7"*(len(str(k))-1)
while True:
    tmp += "7"
    if int(tmp)%k == 0:
        print(len(tmp))
        exit()