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:
from collections import deque

mod = 10**5
def I(): return int(input())
def LI(): return list(map(int,input().split()))
def MI(): return map(int,input().split())
def LLI(n): return [list(map(int, input().split())) for _ in range(n)]
k = input()
K = int(k)

if(K%2==0 or K%5==0):
  print("-1")
  exit()
a = ["7"]*(K-1)
num = "".join(a)
num = int(num)
if(num % K == 0):
  print(K-1)
  exit()
  
count = len(k)
a = ["7"]*(count)
num = "".join(a)
num = int(num)
flag = 0
while count < mod:
  if(num%K==0):
    flag = 1
    break
  num += 7*(10**count)
  count += 1
if(flag == 1):
  print(count)
else:
  a = ["7"]*(K-1)
  num = "".join(a)
  num = int(num)
  if(num % K == 0):
    print(K-1)
  else:
    print("-1")

Submission status: Runtime Error

Solution code:
#https://atcoder.jp/contests/agc008/submissions/15248942
import sys
import math

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

def isPrime(n):
    isP = True
    i = 2
    while (i*i <= n) :
        if n % i == 0:
            isP = False
        i += 1
    
    return isP

K = ini()
isP = isPrime(K)

if isP == False:
    print("-1")
elif: K == 2 or K == 5:
    print("-1")
else:
    print("3")

Submission status: Runtime Error

Solution code:
import math

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

    seven_yes = num % 7
    eleven_yes = num % 11
    mod_value = 1

    count = 1
    
    if num % 2 != 0:
    
        if seven_yes == 0 or eleven_yes == 0 or num < 10000:
        
            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(num-1)

    else:
    
        print(-1)


def is_prime(n):
    if n == 1: 
        return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True


if __name__ == '__main__':
    Repsept()

Submission status: Runtime Error

Solution code:
def check(k):
  d = 0
  i = 0
  while True:
    d = (d * 10) + 7
    i += 1
    if (d % k) == 0:
      break
    if 10 ** 6 <= i:
      i = -1
      break
  return i

k = int(input())
if k == 2:
  print(-1)
elif (7 % k) == 0:
  print(1)
else:
  print(check(i))

Submission status: Runtime Error

Solution code:

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

import numpy as np
# 行数
K = int(input())
flg=False
if K%2==0:
# if K%2==0 or K%5==0:
  print(-1)


else:
  num = 7;
  if K>50000:
    for i in range(50000):
      # print(num)
      if num%K==0:
        flg=True
        print(i+1)
        break
      else:
        num=num*10+7
  else:
    for i in range(np.sqrt(K),0,-1):
      # print(num)
      if num%K==0:
        flg=True
        print(i+1)
        break
      else:
        num=num*10+7


  if is_prime(K) and flg==False:
    print(K-1)
  elif(flg==False):
    print(-1)




# # S =[1]*N
# stock = 0 #株の数
# money = 1000 #所持金
# for i in range(N):
#   if i>0:
#     if A[i-1]<A[i]: #売る
#       money += stock*A[i]
#       stock = 0
#   if i!=N-1:
#     if A[i]<A[i+1]: #買う
#       stock += int(money/A[i])
#       money -= stock*A[i]
# print(money)

Submission status: Runtime Error

Solution code:
k = int(input())
i = len(str(k))
cnt = 0
kanou = ["1","3","7","9"]
hukanou = ["0","2","4","5","6","8"]
if (str(k)[len(str(k))-1]) in kanou:
    cnt = 0
    for i in range(i):
        if str(k)[i] in hukanou:
            cnt = 1
            break
    if cnt == 0:
        while True:
            if(int('7'*i))%k==0:
                cnt = 1
                break
            else:
                i += 1
        print(i)
    elif cnt == 1:
        if k%7==0 and k%3==0:
            print(k)
        else:
            print(k-1)
else:
    print(-1)

Submission status: Runtime Error

Solution code:
x=input()
ans=-1
A='7'
B='7'
for v in range(7777777):
    if((int(A))%x==0):
        ans=int(A)
    A=A+B
print(len(str(ans)))

Submission status: Runtime Error

Solution code:
k = int(input())
sevenList = [7, 77, 777, 7777, 77777, 777777, 7777777, 77777777, 777777777, 7777777777, 77777777777, 777777777777, 7777777777777, 77777777777777]
resList = []
for i in sevenList:
    x = i % k
    if x == 0:
        resList.append(i)
print(len(str(resList[0])))

Submission status: Runtime Error

Solution code:
def check(k):
  d = 0
  i = 0
  while True:
    d = (d * 10) + 7
    i += 1
    if (d % k) == 0:
      break
  return i

k = int(input())
if k == 2:
  print(-1)
elif (7 % k) == 0:
  print(1)
else:
  print(check(i))

Submission status: Runtime Error

Solution code:
k = int(input())

if 7 % k == 0:
    print(1)
    return

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



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

if ans == 0:
    print(-1)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(100000000)

K=int(input())

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

i=1
seven = "7"

while int(seven)/K!=int(seven)//K:
  seven += "7"
  i += 1

print(i)

Submission status: Runtime Error

Solution code:
K=int(input())
num=0
flag=0
limit=10**6
if K%2==0 or K%5==0:
    print(-1)
else:
    if K<limit/2: 
        for i in range(1, limit):
            if 7/9*(10**i-1)%(K)==0:
                print(i)
                flag=1
                break
    else:
        for i in range(limit,1 -1):
            if (10**i-1)%(9/7*K)==0:
                print(i)
                flag=1
                break
    if flag==0:
        print(-1)

Submission status: Runtime Error

Solution code:
b=0
i=0
if K%2==0:
  print(-1)
else:
  while True:
    a=10**i
    b=b+7*a
    i+=1
    if b%K==0:
      print(i)
      break

Submission status: Runtime Error

Solution code:
k = int(input())

if 7 % k == 0:
    print(1)
    return

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



ans = 0
prev = 7
for i in range(1000000):
    prev = nownum * 10 + 7
    if prev % k == 0:
        print(i+2)
        ans = 1
        break

if ans == 0:
    print(-1)

Submission status: Runtime Error

Solution code:
K = int(input())  # ぜんぜんちがう
ans = -1

def moduloseven(K):
	for i in range(1000):
		sev = int(str(7)*(i+1))
		if sev % K == 0:
			ans = i+1
			break
	return(ans)


if K % 2 != 0:
	if K % 5 != 0:
		ans = moduloseven(K)
print(ans)

Submission status: Runtime Error

Solution code:
k = int(input())

if 7 % k == 0:
    print(1)
    return

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



ans = 0
prev = 7
for i in range(1000000):
    prev = nextnum(prev)
    if prev % k == 0:
        print(i+2)
        ans = 1
        break

if ans == 0:
    print(-1)

def nextnum(nownum):
    return nownum * 10 + 7

Submission status: Runtime Error

Solution code:
n=int(input())
c=input()
count=0

for i in range(n):
  if c[i]=='W':
    #print('when W in',i)
    s=c[i:]
    num=s.find('R')
    if num<0:
      break
    num+=i
    #print('when num ',num)
    t=c[num:]
    num_ch=t.find('W')
    if num_ch<0:
      num_ch=n-num   
    #print(num_ch)
    num_ch+=num
    
    #print('when num_ch',num_ch)
    if num-i-1<=num_ch-num:
      #print('間が小さいので塗り替える')
      for j in range(i,num):
        #print(j)
        c=c[:j]+'R'+c[j+1:]
        count+=1
    else:
      #print('間が大きいので交換する')
      for j in range(num,num_ch):
        #print(j)
        c=c[:j]+'W'+c[j+1:]
        c[i+j-num]='R'
        count+=1
#print(c)
print(count)

Submission status: Runtime Error

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

import math



def power_func(a,n,p):
        bi = str(format(n,"b"))#2進表現に
        res = 1
        for i in range(len(bi)):
            res = (res*res) %p
            if bi[i] == "1":
                res = (res*a) %p
        return res
    
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

N = int(input())
if N%7 == 0:
    N = N//7

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

else:
    a = 1
    i = 1
    
    A = factorization(N)
    
    g = 1
    
    for n in A:
        if n[0] == 3:
            k_f = 3
        else:
            N = n[0]*9
            K = make_divisors(n[0]-1)
            for k in reversed(K):
                a = power_func(10,k,N)-1
                if a == 0:
                    k_f = k
        g = g*k_f*n[0]**(n[1]-1)//math.gcd(g,k_f*n[0]**(n[1]-1))
    print(g)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
k=int(input())
for i in range(10000000):
    if (7/9)*((10**(i+1)-1))%k==0:
        break

if (7/9)*((10**(i+1)-1))%k==0:
    print(i+1)
else:
     print("-1")

Submission status: Runtime Error

Solution code:

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

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

    d = {}
    for t in [1, 3, 7, 9]:
        d[t] = {}
        for i in range(10):
            d[t][t * i % 10] = i
    
    td = k % 10
    curr = 0
    count = 0
    while count == 0 or curr != 0:
        diff = 7 - (curr % 10)
        if diff != 0:
            if diff < 0:
                diff += 10
            coef = d[td][diff]
            curr += coef * k
        curr //= 10
        count += 1

    print(count)
    

submit()

Submission status: Runtime Error

Solution code:
K=int(input())

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

i=1
seven = "7"

while int(seven)/K!=int(seven)//K:
  seven += "7"
  i += 1

print(i)

Submission status: Runtime Error

Solution code:
k=int(input())
#k*=9
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]
if k%7==0:
    k//=7
if k%2==0 or k%5==0:
    print(-1)
else:
    i=1
    s=10
    while s%k!=1:
        s=s*10%k
        i+=1
print(i)

Submission status: Runtime Error

Solution code:
K=int(input())
N=1
c=0
if K%2==0:
    print("-1")
else:
    while N % K != 0:
        c += 1
        N = int(7 * (10 ** c - 1) / (10 - 1))
print(c)

Submission status: Runtime Error

Solution code:
from collections import deque

mod = 10**7
def I(): return int(input())
def LI(): return list(map(int,input().split()))
def MI(): return map(int,input().split())
def LLI(n): return [list(map(int, input().split())) for _ in range(n)]
k = input()
K = int(k)

if(K%2==0 or K%5==0):
  print("-1")
  exit()
a = ["7"]*(K-1)
num = "".join(a)
num = int(num)
if(num % K == 0):
  print(K-1)
  exit()
  
count = len(k)
flag = 0
num = 0
for i in range(count):
  num += 7*(10**i)
while count < K:
  if(num%K==0):
    flag = 1
    break
  num += 7*(10**count)
  count += 1
if(flag == 1):
  print(count)
else:
  print("-1")

Submission status: Runtime Error

Solution code:
import sympy
import math



def power_func(a,n,p):
        bi = str(format(n,"b"))#2進表現に
        res = 1
        for i in range(len(bi)):
            res = (res*res) %p
            if bi[i] == "1":
                res = (res*a) %p
        return res
    
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

N = int(input())
if N%7 == 0:
    N = N//7

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

else:
    a = 1
    i = 1
    
    A = factorization(N)
    
    g = 1
    
    for n in A:
        if n[0] == 3:
            k_f = 3
        else:
            N = n[0]*9
            K = sympy.divisors(n[0]-1)
            for k in reversed(K):
                a = power_func(10,k,N)-1
                if a == 0:
                    k_f = k
        g = g*k_f*n[0]**(n[1]-1)//math.gcd(g,k_f*n[0]**(n[1]-1))
    print(g)

Submission status: Runtime Error

Solution code:
k = int(input())
i = int(str(k)[-1])
if(i % 2 == 0 | i % 5 == 0 ):
    print(-1)
else:
    numl = [0]*k
    num = 7
    for i in range(k):
        numl[i] = num
        num = 7+ num*10
        
    for i in range(k):
        if(numl[i] % k == 0):
            break
        else:
            result=i+1
    else:
        result = -1
    print(result)

Submission status: Runtime Error

Solution code:
import sympy

n = int(input())

if n % 2 == 0 or n % 5 == 0:
    print(-1)
else:
    divisors = sympy.divisors(n - 1)
    for i in divisors:
        if (10 ** i % n) == 1:
            print(i)
            exit(0)
    print(-1)

Submission status: Runtime Error

Solution code:
import math

k = int(input());

if k % 2 == 0 or k % 5 == 0:
  ans = -1
elif k == 7:
  ans = 1
else:
  for i in range(1,2000000):
    an = (10 ** i - 1)/9;
    if an % k == 0:
      ans = i
      break

print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
st = input()

r = st.count("R")

count = 0

for i in range(r):
    if st[i]=="W":
        count += 1

print(count)

Submission status: Runtime Error

Solution code:
def main():
    K = int(input())
    if K%2 == 0:
        return -1

    amari_sum = 0
    i = 1
    amari = 7 % K
    amari_sum += amari
    if amari == 0:
        return i

    while True:
        i += 1
        if
        amari = (amari*10) % K
        amari_sum += amari
        if amari_sum % K == 0:
            return i
        else:
            amari_sum %= K

print(main())

Submission status: Runtime Error

Solution code:
K = int(input())
if(K%2==0):
    print(-1)
    exit()
check=list(str(K))
if(check[-1]=='5'):
    print(-1)
    exit()
else:
    seven=7
    if(int(''.join(['7']*(K-1)))%K==0):
        print(K-1)
        exit()
    while True:
        if(seven%K==0):
            print(len(str(seven)))
            break
        else:
            seven=seven*10+7

Submission status: Runtime Error

Solution code:

def next7(s):
    return s * 10 + 7


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

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

    d = {}
    for t in [1, 3, 7, 9]:
        d[t] = {}
        for i in range(10):
            d[t][t * i % 10] = i
    
    td = k % 10
    curr = 0
    digit = 1
    count = 0
    while count == 0 or curr != 0:
        diff = 7 - (curr % 10)
        if diff != 0:
            if diff < 0:
                diff += 10
            coef = d[td][diff]
            curr += coef * k
        curr //= 10
        count += 1

    print(count)
        


submit()

Submission status: Runtime Error

Solution code:
#include<iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main()
{
  
  int X;
  cin >> X;
  
  a = 1;
  n = 7;
  l = 10 ** 18;
  p = X % 2;
  
  vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(n / i);
        }
    }
    return ret;
    
    while() {
      if (p ==0) {
        print(-1)
        break;
      }
      m = divisor(n)
      if (std::find(m.begin(), m.end(), X) != m.end()) {
        print(a)
        break;
      }
      if (n >= l) {
        print(-1)
        break;
      }
      else {
        a = a +1
        n = n * 10 + 7
      }
    }
}

Submission status: Runtime Error

Solution code:
K = int(input())
n = 1000000
ans = -1
for i in n:
  ai = 7*(1 +(10**i - 10)/9)
  if ai%K == 0:
    ans += i+1
    break
print(ans)

Submission status: Runtime Error

Solution code:
N=int(input())
if N%2==0:
    print(-1)
    exit()
num=7
ans=-1
for i in range(1,10*8):
    if num%N==0:
        ans=i
        break
    num=str(num)
    num+='7'
    num=int(num)
if i ==79:
    print(N-1)
else
    print(ans)

Submission status: Runtime Error

Solution code:
k = int(input())
c = 0
a = [0]*(k+1)
a[0] = 7%k

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

Submission status: Runtime Error

Solution code:
k=int(input())
#k*=9
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]
if k%7==0:
    k//=7
if k%2==0 or k%5==0:
    print(-1)
else:
    for j in make_divisors(k-1):
        s=1
        for p in range(j):
            s=s*10%k
        if s==1:
            break
    print(j)

Submission status: Runtime Error

Solution code:
#c
k=int(input())
if k%7==0:
    k/=7
if k%2==0:
    ans=-1
else:
    x=1
    ans=-1
    plus=10
    for i in range(1,10000000):
        if x%k==0:
            ans=i
            break
        else:
            x+=plus
            plus*=10
print(ans)

Submission status: Runtime Error

Solution code:
K = int(input())
n = 1000000
ans = -1
for i in n:
  ai = 7*(1 +(10**i - 10)/9)
  if ai%K = 0:
    ans += i+1
    break
print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np
k = np.int64(int(input()))

Moji = ''
if k % 2 ==0:
  print(-1)
elif str(k)[0] == 5:
  print(-1)
elif k  < np.sqrt(777777777777.0):
  for i in range(10**6):
    Moji += '7'
    if np.int64(int(Moji))%k == 0:
      print(i+1)
      break
      
else:
  print(k-1)

Submission status: Runtime Error

Solution code:
#!/usr/bin python3
# -*- coding: utf-8 -*-

k = int(input())
if k%2==0:
    print(-1)
else:
    ret = len(str(k))-1
    x = int('7'*(len(str(k))-1))
    res = x%k
    while res != 0:
        res = (res * 10 + 7) % k
        ret += 1
    print(ret)

Submission status: Runtime Error

Solution code:
from sys import stdin

K = int(stdin.readline().rstrip())
if K % 2 = 0:
  print(-1)
a_n = 7
i = 1
while True:
  if a_n < K:
    print(-1)
    break
  if a_n % K == 0:
    print(i)
    break
  else:
    i += 1
    a_n = a_n * 10 + 7

Submission status: Runtime Error

Solution code:
import math
bai7 = [7,9,0,1,3]

k = int(input())
if k % 2==0 or k %5 == 0:
    print(-1)
else:
    keta1 = k % 10
    bai = bai7[keta1//2+1]
    sub_k = k * bai
    keta = math.floor((math.log(sub_k ,10)))
    n = keta
    p = 0
    for i in range(keta):
        p += 7*(10**(i))

    while(p < k*k):
        if p % k ==  0:
            print(n)
            break
        else:
            n += 1
            p  += 7  *  10**(n-1)

Submission status: Runtime Error

Solution code:
k=input()
just=7
cnt=1
i=1
if k%2==0:
	print(-1)
else:
    while i == 1:
        if just%k==0: 
            print(cnt)
        if just%k==0:
            break
        cnt+=1
        just=just*10+7

Submission status: Runtime Error

Solution code:
import sys

def sosu(num):
    flag=0
    for i in range(2,num):
        if num%i==0:
            flag=1
            break
    return flag

count=1;
k=int(input())
if k%2==0 or k==5:
	print('-1')
else:
	if sosu(k)==0:
		i=7;
		while(1):
			if i%k==0:
				print(count)
				break
			i=i*10+7
			count+=1
	elif k%7==0 and sosu(k/7)==0:
		i=7;k/=7;
		while(1):
			if i%k==0:
				print('count')
				break
			i=i*10+7
			count+=1
		else:
			print('-1')

Submission status: Runtime Error

Solution code:
import math
bai7 = [7,9,0,1,3]

k = int(input())
if k % 2==0 or k %5 == 0:
    print(-1)
else:
    keta1 = k % 10
    bai = bai7[keta1//2+1]
    sub_k = k * bai
    keta = math.floor((math.log(sub_k ,10))) 
    n = keta
    p = 0
    for i in range(keta):
        p += 7*(10**(i))

    while(True):
        if p % k ==  0:
            print(n)
            break
        else:
            n += 1
            p  += 7  *  10**(n-1)

Submission status: Runtime Error

Solution code:
K=input()
if K%2==0 or K[-1]==5:
    print(-1)
else:
    for i in range(9999999999999):
        b=i**4+i**9

Submission status: Runtime Error

Solution code:
import numpy as np
k = int(input())

Moji = ''
if k % 2 ==0:
  print(-1)
elif str(k)[0] == 5:
  print(-1)
elif k  < np.sqrt(77777777777777777777):
  for i in range(10**6):
    Moji += '7'
    if int(Moji)%k == 0:
      print(i+1)
      break
      
else:
  print(k-1)

Submission status: Runtime Error

Solution code:
k = int(input())
s = 7
c = 1
While c <= 10*6
if s % k == 0:
  print(c)
  break
else:
  c += 1
  s = int("7"*c)

Submission status: Runtime Error

Solution code:
def is_prime(a):
    if a == 1:
        return False
    i = 2
    while i * i <= a:
        if a % i == 0:
            return False
        i += 1
    return True

K = int(input())

if not is_prime(K) or K == 2:
    print(-1)

else:
    exit(1)
    print(K - 1)

Submission status: Runtime Error

Solution code:
K=int(input())
if K%2==0 or K[-1]==5:
    print(-1)
else:
    pass

Submission status: Runtime Error

Solution code:
k = int(input())
if k %2 == 0 or k % 5 ==0:
  print(-1)
else:
  def divisor(n): 
      i = 1
      table = []
      while i * i <= n:
          if n%i == 0:
              table.append(i)
              table.append(n//i)
          i += 1
      table = list(set(table))
      return table
  rts = divisor(k)
  print(rts[1]-1)

Submission status: Runtime Error

Solution code:
import math

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

    mod_value = 1

    count = 1
    
    

    if num % 2 != 0:

        if is_prime(num):
                    
            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(num-1)
        
    else:
    
        print(-1)

def is_prime(n):
    if n == 1: 
        return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

if __name__ == '__main__':
    Repsept()

Submission status: Runtime Error

Solution code:
##a = int(stdin.readline().rstrip())
##b, c = [int(x) for x in stdin.readline().rstrip().split()]
##s = stdin.readline().rstrip()
##a = list(set(b))  重複を削除
##a = list(map(int,[int(x) for x in stdin.readline().rstrip().split()])) a[0, 1, 2, ...]
##a = [[0] * 2 for _ in range(n)]  a[0,0]
##v = [s[i: i+2] for i in range(0, len(s), 2)]
##  s="12345678" を v=["12","34","56","78"] にするイメージ
##s = "".join(list)リストを文字列に変換[""]は区切り文字
##a.sort(key=itemgetter(1))リストをソートできるよ(from operator import itemgetterが必要)
##sort_p = sorted(p) 昇順ソート

# -*- coding: utf-8 -*-
from sys import stdin
from operator import itemgetter
from collections import deque, Counter
import math
import pprint
from functools import reduce
import numpy as np
import random
import bisect
import copy
# stdin = open("sample.txt")


MOD = 1000000007
INF = float('inf')
alpha = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]

def keta(kazu): # 入力されたintを桁ごとに分解，リストで出力
    kazu_str = str(kazu)
    kazu_list = [int(kazu_str[i]) for i in range(0, len(kazu_str))]
    return kazu_list

def gcd(*numbers): # 最小公倍数
    return reduce(math.gcd, numbers)

def combination(m,n): # mCn
    
    if n > m:
        return 'すまん'
    return math.factorial(m) // (math.factorial(m-n) * math.factorial(n))

def pow_k(x,n):  # (x**n)の計算の高速化
    if n == 0:
        return 1
    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x
        x *= x
        n //= 2
    return K * x

def fact(n): # nの素因数分解の結果を辞書で出力 fuct(24) → {2: 3, 3: 1}
    arr = {}
    temp = n
    for i in range(2,int(n**0.5)+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr[i] = cnt
    if temp != 1:
        arr[temp] = 1
    if arr == {}:
        arr[n] = 1
    return arr
    
def main():
    K = int(stdin.readline().rstrip())
    if K % 2 == 0 or K % 5 == 0:
        print("-1")
    else:
        for n in range(1,1000000):
            an = ((10*(10**(n-1))-1)//9)*7
            if an % K == 0:
                print(n)
                break
        if n == 1000000:
            print("-1")
        
    
main()

Submission status: Runtime Error

Solution code:
import numpy as np
K = int(input())

if K % 2 == 0:
	print(-1)
else:
	vals = ['7', '77' , '777', '7777', '77777']
	loop_cnt = 0
	while True:
		index = np.where(np.array(list(map(int, vals))) % K == 0)[0]
		if len(index) == 0:
			vals = list(map(lambda x: x +'77777', vals))
			loop_cnt += 1
			continue
		else:
			ans = index[0] + 1 + 5 * loop_cnt
			break
	print(ans)

Submission status: Runtime Error

Solution code:
x = int(input())

ng = np.array([2,4,5,6,8])

import numpy as np

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

a = prime_factorize(x)

if len(set(a) & set(ng))>0:
    print(-1)
elif len(set(a))== 1 and len(str(x))>3:
    nana = "7"*(x)
    while True:
        nana = nana[:len(nana)-1]
        if int(nana)%x ==0:
            break
    print(len(nana))
else:
    nana = "7"*(len(str(x)))
    while True:
        nana += "7"
        if int(nana)%x ==0:
            break
    print(len(nana))

Submission status: Runtime Error

Solution code:
import math

K = input()
sevn = 7
while True:
    if K < 7:
        print(-1)
        break
    f, i = math.modf(sevn / K)

    if f == 0.0:
        print(len(str(sevn)))
        break
    sevn = str(sevn) + '7'
    sevn = int(sevn)
    print(sevn)

Submission status: Runtime Error

Solution code:
k = input()
sevens = 7
ok=False
cnt=0
while True:
    cnt++
    if sevens >= k and sevens % k == 0:
        print(cnt)
	ok = True
	break
    sevens *= 10
    sevens += 7
if not ok:
    print(-1)

Submission status: Runtime Error

Solution code:
import numpy as np
k = int(input())

if str(k)[0] % 2 ==0:
  print(-1)
elif str(k)[0] == 5:
  print(-1)
else:
  print(4)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import numpy as np
K=int(input()) 

S=""
count=-1

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

print(count)

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**15
p = X % 2

while True:
    if p == 0:
        print(-1)
        break;
    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:
k = int(input())

if k%2 == 0:
    print(-1)
    exit()
elif k == 1:
    print(1)
    exit()
elif k == 11:
    print(2)
    exit()
elif k == 101:
    print(4)
    exit()
elif 1001%k == 0:
    print(6)
    exit()
elif 10001%k == 0:
    print(8)
    exit()
elif 100001%k == 0:
    print(10)
    exit()
elif 1000001%k == 0:
    print(12)
    exit()
elif 10000001%k == 0:
    print(14)
    exit()
elif 100000001%k == 0:
    print(16)
    exit()
elif 1000000001%k == 0:
    print(18)
    exit()
elif 10000000001%k == 0:
    print(20)
    exit()
k = int(input())

if k%2 == 0:
    print(-1)
    exit()
elif k == 1:
    print(1)
    exit()
elif k == 11:
    print(2)
    exit()
elif k == 101:
    print(4)
    exit()
elif 1001%k == 0:
    print(6)
    exit()
elif 10001%k == 0:
    print(8)
    exit()
elif 100001%k == 0:
    print(10)
    exit()
elif 1000001%k == 0:
    print(12)
    exit()
elif 10000001%k == 0:
    print(14)
    exit()
elif 100000001%k == 0:
    print(16)
    exit()
elif 1000000001%k == 0:
    print(18)
    exit()
elif 10000000001%k == 0:
    print(20)
    exit()
elif 100000000001%k == 0:
    print(22)
    exit()
elif 1000000000001%k == 0:
    print(24)
    exit()
elif 10000000000001%k == 0:
    print(26)
    exit()
else:
    print(k-1)

Submission status: Runtime Error

Solution code:
n=int(input())
if n%2==0 or n%5==0:
    print(-1)
else:
    count=1
    flag=0
    num=7
    while flag==0:
        if num%n==0:
            flag=1
        else:
            num=num*10+7
            count=count+1
print(count)

Submission status: Runtime Error

Solution code:
import math

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

k = int(input())

if k % 2 == 1:
    i = 1
    while True:
        if repsept(i) % k == 0:
            break
        i += 1
    print(i)
else:
    print(-1)

Submission status: Runtime Error

Solution code:

import sys

N = input()

if int(N[-1]) in a :
    print(-1)
    sys.exit()
    
N = int(N)

K = "7"

for i in range(1000000):
    S = int(K)
    if S % N == 0:
        print(i+1)
        sys.exit()
    K = K + "7"

print(-1)

Submission status: Runtime Error

Solution code:
K = float(input())

seven = ['7']

i = 0

while True:
    if K % 2 == 0:
        print(-1)
        break
    
    seven.append(seven[i] + '7') 
    print(seven)

    if float(seven[i]) % K == 0:
        print(i+1)
        break

    del seven[0]