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: Runtime Error

Solution code:
import sympy

X = int(input())

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]

a = 1
n = 7
l = 10**12

while True:
    m = make_divisors(n)
    if X in m:
        print(a)
        break;
    if n > l:
        print(-1)
        break;
    else:
        a+=1
        n = n * 10 + 7

Submission status: Runtime Error

Solution code:
import math

def repsept(n):
    return 7 * ((math.pow(10, n) - 1) / 9)

k = int(input())
i = 1
while True:
    if repsept(i) % k == 0:
        break
    i += 1

print(i)

Submission status: Runtime Error

Solution code:
import sympy

X = int(input())

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]

a = 1
n = 7
l = 10**12

while True:
    m = make_divisors(n)
    if X in m:
        print(a)
        break;
    if bool(n > l):
        print(-1)
        break;
    else:
        a+=1
        n = n * 10 + 7

Submission status: Runtime Error

Solution code:
K=int(input())
ans=-1
cc=0

if K%2==0:
    print(ans)

elif K%7==0:
    for i in range(1,K+1):
        cc=int('1'*i)
        if cc%(K/7)==0:
            ans=i
            break
            
    print(ans)
    
else:
    for j in range(1,K+1):
        cc=int('1'*j)
        if cc%K==0:
            ans=j
            break
    print(ans)

Submission status: Runtime Error

Solution code:
N = int(input())
rw = list(input())

rw_after=sorted(rw)

count=0
for i in range(N):
    if rw[i] != rw_after[i]:
        count+=1
print(int(count/2))

Submission status: Runtime Error

Solution code:
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <vector>
#include <stdio.h>
#include <math.h>
#include <string.h>
using namespace std;
typedef long long ll;

//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく

//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

using namespace std;

int main(void){
 
  ll k;
  cin >> k;
  int a = 0;
  int ans = -1;
  REP(i,k){
    a = a * 10 + 7;
    a = a%k;
    if( a == 0){
      ans = i+1;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}

Submission status: Runtime Error

Solution code:
n = int(input())
if n % 2 == 0 or n % 5 == 0:
    pront(-1)
else:
    k = n - 1
    while k % 5 == 0:
        k = k // 5
    print(k)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
import sys
k=int(input())
n=-1
if k%2==0:
  print(n)
  sys.exit()
l=1
while True:
  s=(7*(10**l-1))/9
  if s%k==0:
    print(l)
    break
  l+=1

Submission status: Runtime Error

Solution code:
#include<iostream>
using namespace std;

int main(){
    int k;
    int n=7;
    int count=1;

    cin>>k;

    while(n%k != 0){
        if(k%2==0){
            count=-1;
            break;
        }
        else if(k%5==0){
            count=-1;
            break;
        }
        n=10*n+7;
        count++;
    }
    cout<<count<<"\n";

}

Submission status: Runtime Error

Solution code:
k = int(input())
nums = ""
ans = []
number = 0
if k % 2 == 1:
    for _ in range(15):
        nums += "7"
        if int(nums) % k == 0:
            number = int(nums)
            break
    for i in range(2, k + 1):
        if number % i == 0:
            ans.append(i)
    if max(ans) <= 10 ** 6:
        print(ans.index(k) + 1)
    else:
        print(-1)
else:
    print(-1)

Submission status: Runtime Error

Solution code:
def main():
    k = int(input())
    
    if k == 7:
        print(1)
        sys.exit()
    
    r = 7%k
    g = {r}
    ans = 1
    while True:
        ans+=1
        r = (10*r+7)%k
        if r==0:
            print(ans)
            break
        if r in g:
            print(-1)
            break
        else:
            g.add(r)
main()

Submission status: Runtime Error

Solution code:
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <vector>
#include <stdio.h>
#include <math.h>
#include <string.h>
using namespace std;
typedef long long ll;

//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく

//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

using namespace std;

int main(void){
 
  ll k;
  cin >> k;
  int a = 0;
  int ans = 0;
  REP(i,k){
    a = a * 10 + 7;
    a = a%k;
    if( a == 0){
      ans = i+1;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
#include<iostream>
using namespace std;

int main(){
    int k;
    int n=7;
    int count=1;

    cin>>k;

    while(n%k != 0){
        if(k%2=0){
            count=-1;
            break;
        }
        else(k%5=0){
            count=-1;
            break;
        }
        n=10*n+7;
        count++;
    }
    cout<<count<<"\n";

}

Submission status: Runtime Error

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

isSo = True
for i in range(int(math.sqrt(K)+1)):
    if(i == 0 or i == 1):
        continue
    if(K % i == 0):
        isSo = False
if(K % 2 == 0 or K % 5 == 0):
    print(-1)
elif(K == 3):
    print(3)
elif(K == 7):
    print(1)
elif(isSo):
    print(K-1)
else:
    n = 1
    ans = 0
    while(1):
        rep = (pow(10,n) - 1) / 9
        if(rep % K == 0):
            ans = n
            break
        n += 1
    print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
A = int(input())

if A>777777:
  print(-1)
elof A<7:
  print(-1)
elif A<=7 and 7%A==0:
  print(1)
elif A<=77 and 77%A==0:
  print(2)
elif A<=777 and 777%A==0:
  print(3)
elif A<=7777 and 7777%A==0:
  print(4)
elif A<=77777 and 77777%A==0:
  print(5)
elif A<=777777 and 777777%A==0:
  print(6)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
K = int(input())

n = 1
x = 7


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

while 1:
  if x % K == 0:
    print( n )
    break
  x = (x % K) * 3 + 7
  n += 1
#

Submission status: Runtime Error

Solution code:
K = input()
s = '7'
count = 1

if int(K) % 2 == 0:
    print('-1')
else:
    while int(s) % K != 0:
        s = s + '7'
        count += 1
    print(count)

Submission status: Runtime Error

Solution code:
from math import gcd


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]

k = int(input())
ans = {2: -1, 3: 1, 5: -1, 7: 1}
if k in ans:
    print(ans[k])
if k % 7 == 0:
    k //= 7

p = make_divisors(k-1)
for i in p:
    if int('7' * i) % p == 0:
        print(i)

Submission status: Runtime Error

Solution code:
K = int(input())
plus = 70
seven = 7
if len(prime_factorize(K)) == 1:
    print(K-1)
    exit(0)
print(prime_factorize(K))
cnt = 1
if K%2 ==0:
    print(-1)
    exit(0)
for i in range(1000000):
    if seven%K == 0:
        print(cnt)
        exit(0)
    seven += plus*10**i
    cnt += 1

Submission status: Runtime Error

Solution code:
K= int(input())
ans = -1
if K % 2:
  last = "0"
  for i in range(1, 64):
    last += "7"
    if last % K == 0:
      ans = i
      break
print(ans)

Submission status: Runtime Error

Solution code:
k = int(input())
ans = -1
if k % 2 != 0 or k % 5 != 0:
  f = 0
  m = 1
  seven = ['7']
  q = int(str(k)[-1])
  l = {1: 7, 3: 9, 7: 1, 9: 3}
  m = l[q]
  p = list(set(list(str(k * m))))
  while f == 0:
    if seven == p:
      ans = len(str(k * m))
      break
    else:
      m += 10
      p = list(set(list(str(k * m))))
print(ans)

Submission status: Runtime Error

Solution code:
K = int(input())

n = 1
x = 7


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

while 1:
  if x % K == 0:
    print( n )
    break
  x = (x % K) * 10 + 7
  n += 1
#

Submission status: Runtime Error

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



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

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
K = int(input())
x = [7, 77, 777, 7777, 77777, 777777]
Count = 0
flag="FALSE"
for i in x:
    Count = Count + 1
    if (i % K)==0:
        flag="TRUE"
        break

if flag=="FALSE":
    Count = -1
if K>=777777
    Count = K - 1
print(Count)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N, D = map(int, input().split())
ans = 0
for i in range(N):
    x, y = map(int, input().split())
    if x**2+y**2 <= D**2:
        ans += 1
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
def Repsept():
    
    num = int(input())

    mod_value = 1

    count = 1

    if num % 2 != 0:

        while mod_value != 0:
            value = 7*(pow(10, count)-1)/9.
            
            mod_value = value % num
            
            if mod_value != 0:
                count = count + 1

        print(count)
        
    else:
    
        print(-1)

if __name__ == '__main__':
    Repsept()

Submission status: Runtime Error

Solution code:
K = int(input())

L = '7'
c = 1
a = []
while True:
    k = int(L*c)
    m = k % K
    if k % K == 0:
        print(c)
        exit()
    if a in m:
        print(-1)
        exit()
    a.append(m)
    
    c += 1

Submission status: Runtime Error

Solution code:
import sys
a=int(input())
cnt=1
if a%2==0:
  print(-1)
  sys.exit()
if a%7==0:
  a/=7
for i in range(1,a+1):
  if cnt%a==0:
    print(i)
    sys.exit()
  cnt=cnt*10+1
print(-1)

Submission status: Runtime Error

Solution code:
num = ""
ans = 0
count = 1

divide = int(input())
divided = divide / 2
divided = str(divided)
divided = divided.split(".")

if divided[1] == "0":
    print(-1)
else:
  while ans == 0:
    num += "7"
    Num = int(num)
    res = Num / divide
    res = str(res)
    res = res.split(".")
    if res[1] == "0":
        ans = count
        print(ans)
    else:
        count += 1

Submission status: Runtime Error

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

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


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

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

Submission status: Runtime Error

Solution code:
from sys import stdin
import numpy as np
k = int(stdin.readline().rstrip())

num = 7
ans = 1
#2の偶数は弾く
if  k % 2 == 0 :
  print("-1")
  sys.exit()

while num <= 10**6:
    #処理
    if  num % k == 0:
      break
    ans = ans + 1
    num = (num * 10) + 7
    #巨大数で割り切れなかった時
    if num > 10**6:
      print("-1")
      sys.exit()
print(ans)

Submission status: Runtime Error

Solution code:
k = int(input())

if k == 7:
    ans = 1
elif k % 2 == 0:
    ans = -1
else:
    for i in range(1, (len(str(k)) * 3) + 1):
        idx += 1
        tgt = int("7" * i)
        if tgt % k == 0:
            ans = i
            break

print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
c = [l for l in input()]
max_idx = len(c)-1

if 'W' not in c:
  print(0)
else:
  most_left_white = c.index('W')
  tmp = c[::-1]
  most_right_red = max_idx - tmp.index('R')

  cnt = 0
  while most_left_white<most_right_red:
    c[most_left_white] = 'R'
    c[most_right_red] = 'W'

    most_left_white = c.index('W')
    tmp = c[::-1]
    most_right_red = max_idx - tmp.index('R')
    cnt+=1
  print(cnt)

Submission status: Runtime Error

Solution code:
k = int(input())
t = '7'
i = 0
if k % 2 == 0:
    print(-1)
else:
    while(1):
        s = int(t)
            if s % k == 0:
                ans = i+1
                break
            t += '7'
            i += 1
        print(ans)

Submission status: Runtime Error

Solution code:
k=int(input())
a=[str(7)*x for x in range(1,100)]
b = [int(i) for i in a]
r=[]
for x in b:
    if x%k==0:
        r.append(len(str(x)))
print(r[0])

Submission status: Runtime Error

Solution code:
k = int(input())
ans = -1
if k % 2 == 1:
  f = 0
  m = 1
  while f == 0:
    print(list(str(k * m)))
    if seven % k == 0:
      f = 1
      ans = len(str(seven))
      break
    else:
      seven = int(str(seven) + '7')
print(ans)

Submission status: Runtime Error

Solution code:
K = input()
N = 10 **3
x = 0
for i in range(1, N):
  X += 7 ** 10^i
  if x % K == 0:
    print(i)
    break:
  else:
    print('-1')

Submission status: Runtime Error

Solution code:
k = int(input())
t = '7'
i = 0
if k % 2 == 0:
    print(-1)
while(1):
    s = int(t)
        if s % k == 0:
            ans = i+1
            break
        t += '7'
        i += 1
    print(ans)

Submission status: Runtime Error

Solution code:

k = int(input())
a = '7' * (k - 1)
if int(a) % k == 0:
    for i in range(1, 50):
        a = '7' * i
        if int(a) % k == 0:
            print(i)
            exit()
    print(k-1)
    exit()
print(-1)

Submission status: Runtime Error

Solution code:
""" C
    https://atcoder.jp/contests/abc173/tasks/abc173_c
"""
import sys
import math
from functools import reduce
from bisect import bisect_left

def readString():
    return sys.stdin.readline()

def readInteger():
    return int(readString())

def readStringSet(n):
    return sys.stdin.readline().split(" ")[:n]

def readIntegerSet(n):
    return list(map(int, readStringSet(n)))

def readIntegerMatrix(n, m):
    return reduce(lambda acc, _: acc + [readIntegerSet(m)], range(0, n), [])

def _pattern(N):
    if N > 1:
        pa = _pattern(N-1)
        return [[0] + p for p in pa] + [[1] + p for p in pa]
    else:
        return [[0], [1]]

def main(K):
    if K % 2 == 0
        return -1

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

    return count

if __name__ == "__main__":
    _K = readInteger()

    print(main(_K))

Submission status: Runtime Error

Solution code:
a = "7"
i = 1
n = int(input())
if(n % 2 == 0):
  print("-1")
else:
  while True:
    if(int(a) % n == 0 and int(a) / n != 0):
      break
    i += 1
    a = a + "7"
 
print(i)

Submission status: Runtime Error

Solution code:
x = int(input())
s = '7'
if(x%2==0):
	print("-1")
i=1
b=s*i
else:	
    while(int(b)%x!=0):
  		b=s*i
        i = i+1
        if(int(b)%x==0):
          break
print(i)

Submission status: Runtime Error

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

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

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

Submission status: Runtime Error

Solution code:

k = int(input())
a = '7' * (k - 1)
if int(a) % k == 0:
    for i in range(1, 100):
        a = '7' * i
        if int(a) % k == 0:
            print(i)
            exit()
    print(k-1)
print(-1)

Submission status: Runtime Error

Solution code:
num = "7"
ans = 0
count = 1

divide = int(input())
divided = divide / 2
divided = str(divided)
divided = divided.split(".")

if divided[1] == "0":
    print(-1)
else:
    while ans == 0:
        num += "7"
        Num = int(num)
        res = Num / divide
        res = str(res)
        res = res.split(".")
        if res[1] == "0":
            ans = count + 1
            print(ans)
        else:
            count += 1

Submission status: Runtime Error

Solution code:
k = int(input())

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

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

Submission status: Runtime Error

Solution code:
a = "7"
i = 1
n = int(input())
if(n % 2 == 0):
  print("-1")
else:
  while True:
    if(a % n == 0 and a / n != 0):
      break
    i += 1
    a = a + "7"

print(i)

Submission status: Runtime Error

Solution code:
K = int(input())
T = 1
S = 7
X = 1000000
for i in range(X):
    if S/K == S//K:
        print(T)
        break
    else:
        T += 1
        S = S*10 + 7
if T == 1000001:
    print(-1)

Submission status: Runtime Error

Solution code:
K = int(input())

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

print(ans)

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
using namespace std;

int main() {
    int64_t K;
    cin >> K;

    unordered_set<int64_t> exist_mod;
    int64_t mod = 0;
    for (uint64_t i = 1; true; i++) {
        mod = (mod * 10 + 7) % K;
        if (exist_mod.count(mod) > 0) {
            cout << -1 << endl;
            break;
        }
        if (mod == 0) {
            cout << i << endl;
            break;
        }
        exist_mod.insert(mod);
    }
}

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
k = int(input())
if k % 2 == 0:
  print(-1)
nana = 0
ans = 0
print(len(k))
while True:
  nana += (10**ans) * 7
  #print(nana)
  if nana % k == 0:
    print(ans + 1)
    break
  ans += 1

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
#

import sys
from math import gcd
input=sys.stdin.readline

def main():
    K=int(input())
    if K%2==0:
        print(-1)
        exit()
    if K==5:
        print(-1)
    s=set()
    r=7%K
    rsum=r
    s.add(r)
    for i in range(10**6):
        if rsum==0:
            print(i+1)
            exit()
        r=(r*10)%K
        if r in s:Q
            break
        s.add(r)
        rsum=(rsum+r)%K
    print((i+1)*K/gcd(rsum,K))
    
    
    
if __name__=="__main__":
    main()

Submission status: Runtime Error

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

n = len(ks)

sevn = "7"*(n-1)
#print(sevn)


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

print(-1)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

n = len(ks)

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

print(-1)

Submission status: Runtime Error

Solution code:
import sys
import bisect
from functools import lru_cache
from collections import defaultdict
inf = float('inf')
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**6)
def input(): return sys.stdin.readline().rstrip()
def read():
  return int(readline())
def reads():
  return map(int, readline().split())
K=reads()
mod=7//K
index=1
dic=defaultdict(int)
while(True):
    if mod==0:
        print(index)
        exit
    if dic[mod]==1:
        print(-1)
        exit
    dic[mod]=1
    mod=mod*10+7
    i+=1

Submission status: Runtime Error

Solution code:
K=int(input())
num=7
count=1
while count<=K:
  if num % K == 0:
    print(count)
    brake
  else:
    count += 1
    num = num*10+7
if count == K:
  print(-1)
else:
  print(count)

Submission status: Runtime Error

Solution code:
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし

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

A = [1]
for i in range(K):
    A.append((A[-1]*10) % K)

a = 1
i = 1
while True:
    if a % K == 0:
        print(i)
        break
    else:
        a += A[i]
        a %= K
        i += 1

Submission status: Runtime Error

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