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:
k=int(input())
i=1
while(1):
  if(7*(10**i-1)%9k==0):
    break
  i++
print(i)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
k = int(Input)
x = 7%k
l = []
i = 1
while(True):
    if x in l:
        print('-1')
        break
    if x==0:
        print(i)
        break    
        
    l.append(x)
    x = (x*10+7)%k
    i += 1

Submission status: Runtime Error

Solution code:
def gcd(a, b):
  if a < b:
    return gcd(b, a)
  if b == 0:
    return a
  return gcd(b, a%b)

K = int(input())

if gcd(K, 10) != 1:
  print(-1)
else:
  if K % 7 == 0:
    K/=7
  ans = 1
  cur = 1
  while cur % K != 0:
    cur += pow(10, ans, K)
    ans += 1
  print(ans)

Submission status: Runtime Error

Solution code:
import math
k=int(input())
if k%7==0:k/=7
if math.gcd(10,k)!=1: exit(print(-1))
if k==1: exit(print(1))
v=1
ans=0
while(v!=0):
    v=(v*10+1)%k
    ans+=1 
print(ans+1)

Submission status: Runtime Error

Solution code:
# Hey, there Stalker!!!
# This Code was written by:
# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
# ▒▒╔╗╔═══╦═══╗▒▒▒╔╗▒▒▒
# ▒╔╝║║╔═╗║╔═╗╠╗▒▒║║▒▒▒
# ▒╚╗║║║║║║║║║╠╬══╣║╔╗▒
# ▒▒║║║║║║║║║║╠╣║═╣╚╝╝▒
# ▒╔╝╚╣╚═╝║╚═╝║║║═╣╔╗╗▒
# ▒╚══╩═══╩═══╣╠══╩╝╚╝▒
# ▒▒▒▒▒▒▒▒▒▒▒╔╝║▒▒▒▒▒▒▒
# ▒▒▒▒▒▒▒▒▒▒▒╚═╝▒▒▒▒▒▒▒
# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
#from functools import reduce

#mod=int(1e9+7)
#import resource
#resource.setrlimit(resource.RLIMIT_STACK, [0x100000000, resource.RLIM_INFINITY])
#import threading
#threading.stack_size(2**26)
"""fact=[1]
#for i in range(1,100001):
#    fact.append((fact[-1]*i)%mod)
#ifact=[0]*100001
#ifact[100000]=pow(fact[100000],mod-2,mod)
#for i in range(100000,0,-1):
#    ifact[i-1]=(i*ifact[i])%mod"""
#from collections import deque, defaultdict, Counter, OrderedDict
#from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
#from heapq import heappush, heappop, heapify, nlargest, nsmallest


# sys.setrecursionlimit(10**6) 
from sys import stdin, stdout
import bisect            #c++ upperbound
from bisect import bisect_left as bl              #c++ lowerbound bl(array,element)
from bisect import bisect_right as br             #c++ upperbound
import itertools
from collections import Counter

import collections
import math
import heapq
import re
def modinv(n,p):
    return pow(n,p-2,p)
def cin():
    return map(int,sin().split())
def ain():                           #takes array as input
    return list(map(int,sin().split()))
def sin():
    return input()
def inin():
    return int(input())
  
def Divisors(n) : 
    l = []  
    for i in range(1, int(math.sqrt(n) + 1)) :
        if (n % i == 0) : 
            if (n // i == i) : 
                l.append(i) 
            else : 
                l.append(i)
                l.append(n//i)
    return l

def most_frequent(list):
    return max(set(list), key = list.count) 
def GCD(x,y):
    while(y):
        x, y = y, x % y
    return x

def ncr(n,r,p):                                              #To use this, Uncomment 19-25 
    t=((fact[n])*((ifact[r]*ifact[n-r])%p))%p
    return t

def Convert(string): 
    li = list(string.split("")) 
    return li 

def SieveOfEratosthenes(n): 
    global prime
    prime = [True for i in range(n+1)] 
    p = 2
    while (p * p <= n): 
        if (prime[p] == True): 
            for i in range(p * p, n+1, p): 
                prime[i] = False
        p += 1
    f=[]
    for p in range(2, n): 
        if prime[p]: 
            f.append(p)
    return f
prime=[]
q=[]
def dfs(n,d,v,c):
    global q
    v[n]=1
    x=d[n]
    q.append(n)
    j=c
    for i in x:
        if i not in v:
            f=dfs(i,d,v,c+1)
            j=max(j,f)
            # print(f)
    return j

#Implement heapq
#grades = [110, 25, 38, 49, 20, 95, 33, 87, 80, 90] 
#print(heapq.nlargest(3, grades)) #top 3 largest
#print(heapq.nsmallest(4, grades))
#Always make a variable of predefined function for  ex- fn=len
#n,k=map(int,input().split())
"""*******************************************************"""
def main():
    n=inin()
    if n&1==0:
        print(-1)
    else:
        cnt=1
        temp=0
        z=7
        while temp!=1:
            #print(cnt,int(cnt*str(7)))
           	z=pow(10,cnt-1)*z+7 
            if z%n==0:
                print(cnt)
                break
            else:
                cnt+=1


"""*******************************************************"""
######## Python 2 and 3 footer by Pajenegod and c1729
py2 = round(0.5)
if py2:
    from future_builtins import ascii, filter, hex, map, oct, zip
    range = xrange
 
import os, sys
from io import IOBase, BytesIO
 
BUFSIZE = 8192
class FastIO(BytesIO):
    newlines = 0
 
    def __init__(self, file):
        self._file = file
        self._fd = file.fileno()
        self.writable = "x" in file.mode or "w" in file.mode
        self.write = super(FastIO, self).write if self.writable else None
 
    def _fill(self):
        s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
        self.seek((self.tell(), self.seek(0,2), super(FastIO, self).write(s))[0])
        return s
 
    def read(self):
        while self._fill(): pass
        return super(FastIO,self).read()
 
    def readline(self):
        while self.newlines == 0:
            s = self._fill(); self.newlines = s.count(b"\n") + (not s)
        self.newlines -= 1
        return super(FastIO, self).readline()
 
    def flush(self):
        if self.writable:
            os.write(self._fd, self.getvalue())
            self.truncate(0), self.seek(0)
 
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        if py2:
            self.write = self.buffer.write
            self.read = self.buffer.read
            self.readline = self.buffer.readline
        else:
            self.write = lambda s:self.buffer.write(s.encode('ascii'))
            self.read = lambda:self.buffer.read().decode('ascii')
            self.readline = lambda:self.buffer.readline().decode('ascii')
 
 
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip('\r\n')
if __name__== "__main__":
    main()
#threading.Thread(target=main).start()

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vs = vector<string>;
using vvl = vector<vl>;
using pll = pair<ll,ll>;
using vb = vector<bool>;

const ll oo = 0x3f3f3f3f3f3f3f3fLL;
const double eps = 1e-9;

#define sz(c) ll((c).size())
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define xx first
#define yy second

#define has(c,i) ((c).find(i) != end(c))
#define FOR(i,a,b) for (int i=(a); i<(b); i++)
#define FORD(i,a,b) for (int i=int(b)-1; i>=(a); i--)

#define rv(type,name,count) vector<type> name(count); FOR(_i,0,count) cin >> name[_i];
#define grid(type,name,c1,c2) vector<vector<type>> name(c1, vector<type>(c2)); FOR(_i,0,c1)FOR(_j,0,c2)cin >> name[_i][_j];

int main() {
	ll k;
	cin >> k;
	ll start = k;
	ll div = 0, count = 0;
	while (start) {
		div *= 10;
		div += 7;
		count++;
		start /= 10;
	}
	vector<bool> found(100000000, false);
	while (!found[div]) {
		if (div % k == 0) {
			cout << count << endl;
			return 0;
		}
		found[div] = true;
		div = div % k;
		div *= 10;
		div += 7;
		count++;
	}
	cout << -1 << endl;
}

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vs = vector<string>;
using vvl = vector<vl>;
using pll = pair<ll,ll>;
using vb = vector<bool>;

const ll oo = 0x3f3f3f3f3f3f3f3fLL;
const double eps = 1e-9;

#define sz(c) ll((c).size())
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define xx first
#define yy second

#define has(c,i) ((c).find(i) != end(c))
#define FOR(i,a,b) for (int i=(a); i<(b); i++)
#define FORD(i,a,b) for (int i=int(b)-1; i>=(a); i--)

#define rv(type,name,count) vector<type> name(count); FOR(_i,0,count) cin >> name[_i];
#define grid(type,name,c1,c2) vector<vector<type>> name(c1, vector<type>(c2)); FOR(_i,0,c1)FOR(_j,0,c2)cin >> name[_i][_j];

int main() {
	ll k;
	cin >> k;
	ll start = k;
	ll div = 0, count = 0;
	while (start) {
		div *= 10;
		div += 7;
		count++;
		start /= 10;
	}
	vector<bool> found(10000000, false);
	while (!found[div]) {
		if (div % k == 0) {
			cout << count << endl;
			return 0;
		}
		found[div] = true;
		div = div % k;
		div *= 10;
		div += 7;
		count++;
	}
	cout << -1 << endl;
}

Submission status: Runtime Error

Solution code:

k=int(input())
ans=2
s_1=7%k
s_2=10%k
m=0
j=0
if k%2==0 or k%5==0:
  print(-1)
elif k==1 or k==7:
  print(1)
elif k%7==0:
  l=9*k/7
  s=10%l
  while j==0:
    m=(m+s_1*(s-1))%l
    if m==0:
      j==1
    else:
      ans+=1
      s=(s*10)%l
  print(ans)
else:
  l=9*k
  i=0
  while j==0:
    m=(m+s_1*(s-1))%l
    if m==0:
      j==1
    else:
      ans+=1
      s=(s*10)%l
  print(ans)

Submission status: Runtime Error

Solution code:
k=int(input())
ans=2
s_1=7%k
m=0
j=0
if k%2==0 or k%5==0:
  print(-1)
elif k==1 or k==7:
  print(1)
elif k%7==0:
  l=9*k/7
  i=0
  while j==0:
    m=(m+s_1*(((s_2**i)%l-1)%l))%l
    if m==0:
      j==1
    else:
      i+=1
      ans+=1
  print(ans)
else:
  l=9*k
  s=10%k
  while j==0:
    m=(m+s_1*s)
    if m==0:
      j==1
    else:
      i+=1
      ans+=1
      s=(10*s)%k
  print(ans)

Submission status: Runtime Error

Solution code:
k = int(input())
s = set()
c = 1

while True:
  m = ((10**c * 7 - 7)/9) % k 
  
  
  if m == 0:
    print(c)
    break
  elif m in s:
    print(-1)
    break
    
  s.add(m)
  
  c += 1

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
k = int(input())
if k % 2 == 0:
	print(-1)
elif k % 5 == 0:
	print(-1)
elif k%7 == 0:
	l = 9*k/7
	form = 1
	for i in range(l):
		if form * 10 % l == 1:
			print(i+1)
			break
		else:
			form = form * 10 % l 
else:
	l = 9 * k
	form = 1
	for i in range(l):
		if form * 10 % l == 1:
			print(i+1)
			break
		else:
			form = form * 10 % l

Submission status: Runtime Error

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

flg = True
for i in range(1,k):
  x = x%k
  if x ==0:
    break
  else:
    x = x*10+7
    
if k%2==0:
  flg = False
    
print(i if flg else '-1')

Submission status: Runtime Error

Solution code:
K = int(input())

if K % 7 ==0:
    K /= 7

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

c=1
n=10
while True:
    r = n % (9*K)
    if r == 1:
        print(c)
        break
    n = r * 10
    c += 1

Submission status: Runtime Error

Solution code:
K = int(input())

if K % 7 ==0:
    K /= 7

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

c=1
n=7
while True:
    r = n % K
    if r == 0:
        print(c)
        break
    n = r * 10 + 7
    c += 1

Submission status: Runtime Error

Solution code:
n = input()
m = 0

if n[-1] == "1":
    m = 7
elif n[-1] == "3":
    m = 9
elif n[-1] == "7":
    m = 1
elif n[-1] == "9":
    m = 3
else:
    print(-1)
    exit()

n = int(n)

for i in range(1, k):
    if len(set(list(str(n * m)))) == 1:
        break
    m = int(str(i) + str(m)[-1])
    if len(str(n * m)) >= k:
        print(-1)
        exit()

print(len(str(n * m)))

Submission status: Runtime Error

Solution code:
K = int(input())
remainder_set = set()
sequence = 7
i = 1
for i in range(10**7 + 9):
    if sequence%K == 0:
        print(i+1)
        break
    else:
        if sequence%K in emainder_set:
            print(-1)
            break
        else:
            i += 1
            sequence *= 10
            sequence += 7

Submission status: Runtime Error

Solution code:
K=int(input())
C=False
count=0
for i in range(K):
  count+=1
  if (7(10**i-1))%9*K==0:
    C=True
    break
if C:
  print(count)
else:
  print(-1)

Submission status: Runtime Error

Solution code:
K=int(input())
C=False
count=0
for i in range(K):
  count+=1
  if (7(10**i-1))//9*K==0:
    C=True
    break
if C:
  print(count)
else:
  print(-1)

Submission status: Runtime Error

Solution code:
#include<bits/stdc++.h>

#define ll              long long
#define pb              push_back
#define ff              first
#define ss              second
#define mp              make_pair

#define scan(a)         scanf("%d", &a)
#define scanl(a)        scanf("%lld", &a)
#define scand(a)        scanf("%lf", &a)
#define scan2(a, b)     scanf("%d %d", &a, &b)
#define scanl2(a, b)    scanf("%lld %lld", &a, &b)
#define scand2(a, b)    scanf("%lf %lf", &a, &b)

#define yes             cout << "yes\n"
#define no              cout << "no\n"
#define Case(i)         cout << "Case " << int(i) << ": "

#define lop(n)          for(int i = 0; i < n; i++)
#define lopj(n)         for(int j = 0; j < n; j++)
#define lopr(a, n)      for(int k = a; k < n; k++)
#define lrev(n, a)      for(int i = n; i >= a; i--)

#define all(x)          x.begin(), x.end()
#define mem(a, b)       memset(a, b, sizeof(a))

#define vin             vector <int>
#define vll             vector <ll>
#define vst             vector <string>
#define pll             pair <ll, ll>
#define pss             pair <string, string>
#define vpll            vector <pll>

#define fread           freopen("input.txt", "r", stdin)
#define fwrite          freopen("output.txt", "w", stdout)
#define fastio          ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

#define mod             1000000007
#define PI              acos(-1.0)
#define inf             999999999999


using namespace std;


int main()
{
    fastio;

    int tt, n;

    cin >> tt;

    int x = 7;

    lop(tt)
    {
        if(!x)
        {
            cout << i + 1 << '\n';
            return 0;
        }

        x = (x * 10 + 7) % tt;
    }

    cout << -1 << '\n';

    return 0;
}

Submission status: Runtime Error

Solution code:
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int k; cin >> k;
    int a = 7%k;
    rep(i,k){
        if (a == 0){
            cout << i+1 << "\n";
            return 0;
        }
        a = (a * 10 + 7)%k;
    }
    cout << -1 << "\n";
}

Submission status: Runtime Error

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
n = 1
P = 10 % L
while True:
    if P == 1:
        print(n)
        break
    n += 1
    P = (10 * P) % L

Submission status: Runtime Error

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
n = 1
P = 10 % L
while True:
    if P == 1:
        print(n)
        break
    n += 1
    P = (10 * P) % L

Submission status: Runtime Error

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
n = 1
P = 10 % L
while True:
    if P == 1:
        print(n)
        break
    n += 1
    P = (10 * P) % K

Submission status: Runtime Error

Solution code:
import sys
def input():
    return sys.stdin.readline()[:-1]


def main():
    K = int(input())
    x = 0
    if K % 2 == 0 or K % 5 ==  0:
        print(-1)
  
    while True:
        x = (x * 10 + 7) % K
        i += 1
        if x == 0:
            print(i + 1)
            break


    

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
N=int(input())
C=input()
R=0
for i in C:
    if i=="R":
        R+=1
D=C[:R]
count=0
for i in D:
    if i=="W":
        count+=1
print(count)

Submission status: Runtime Error

Solution code:
import math
K=input()

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

if L%2==0 or L%5==0:
    print(-1)
else:
    r=10%L
    for i in range(1,10**6+1):
        if r==1:
            ans=i
            break
        else:
            r=10*r%L

print(ans)

Submission status: Runtime Error

Solution code:
import math
K=input()

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

if L%2=0 or L%5=0:
    print(-1)
else:
    r=10%L
    for i in range(1,10**6+1):
        if r==1:
            ans=i
            break
        else:
            r=10*r%L

print(ans)

Submission status: Runtime Error

Solution code:
l=[7,77,777,7777,77777,777777,7777777,77777777,777777777,7777777777]
n=int(input())
if n%2==0:
  print(-1)
else:
  for i in range(len(l)):
    if l[i]%n==0:
      print(i+1)
      return

Submission status: Runtime Error

Solution code:
k = int(input())
t = 7
kou = 1

if k % 2 != 0:
  if k % 5 != 0:
    while True:
      kou += 1
      t = 10 * t + 7
    
    if t % k == 0:
    print(kou)
    break

print(-1)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
	int k;
	cin >> k;// mod で考える。k 回 f(x)=10x+7
	int x = 7 % k;
	set<int> s;
	int i = 1;
	while(s.count(x) == 0) {
		if (x == 0) {
			cout << i << endl;
			return 0;
		}
		s.insert(x);
		x = (x * 10 + 7) % k;
		i++;
	}
	cout << -1 << endl;
	return 0;
}

Submission status: Runtime Error

Solution code:
N = int(input())

mod_list = []
if N % 2:
    i = 1
    while True:
        num = (7*((10**i)-1)/9) % N
        if num == 0:
            print(i)
            break
        if num in mod_list:
            print(-1)
            break
        else:
            mod_list.append()
            i += 1

else:
    print(-1)

Submission status: Runtime Error

Solution code:
#C_Repsept
import math
K = int(input())
if K % 7 == 0 :
    L = 9 * K / 7
else:
    L = 9 * K
X = 0
kekka = 1
total = -1
if L % 2 == 1:
    if L % 5 != 0:
        for i in range(L): 
 #           X = pow(10,i) % L
            kekka = kekka * 10 % L
            if kekka == 1:
                total = i+1
                break
# 出力
print(total)

Submission status: Runtime Error

Solution code:
K = int(input())
D = [0]* (10**10)
a=0

for i in range(1,10*10):
    D = int(('7')*i)
    
    if D % K == 0:
        b=i
        a=1
        break

if a==1:
    print(b)
else:
    print('-1')

Submission status: Runtime Error

Solution code:
# AFTER CONTEST

def solve(k):
    if k % 7 == 0:
        k //= 7

    if k % 2 == 0 or k % 5 == 0:
        return -1

    # Min i s.t. k | R(i)
    # by pigeonhole, there exists such i <= k
    r = 1
    for i in range(1, k + 1):
        if r == 0:
            return i
        r = (1 + 10 * r) % k
    raise RuntimeError()


def main(istr, ostr):
    k, = list(map(int, istr.readline().strip().split()))
    result = solve(k)
    print(result, file=ostr)


if __name__ == "__main__":
    import sys

    main(sys.stdin, sys.stdout)

Submission status: Runtime Error

Solution code:
sevens = []
for i in range(7):
    string = '7'*(i+1)
    print(string)
    sevens.append(int(string))

cnt = 1
a = -1
while K*cnt < 10**6:
    num = K*cnt
    if num in sevens:
        a = len(str(num))
        break
    cnt += 1
print(a)

Submission status: Runtime Error

Solution code:
K=int(input())
Check=False
count=0
for i in range(K):
  count+=1
  if (7(10**i-1))//9K==0:
    Check=True
    break
if Check:
  print(count)
else:
  print(-1)

Submission status: Runtime Error

Solution code:
count = 0
before = 0
if k%2 == 0 or k%5==0:
    print(-1)
    exit()

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

Submission status: Runtime Error

Solution code:
import sys
input - sys.stdin.readline
def main():
    K = int(input())
    
    if K%2==0:
        print(-1)
        return
    
    if K % 7:
        L = 9*K
    else:
        L = 9*K//7
    a = 1
    for i in range(1,K+10):
        a = (a * 10) % L
        if a == 1:
            print(i)
            return
    print(-1)
main()

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
import sys
k=int(input())
if k%2==0 or k%5==0:
  print(-1)
  sys.exit()
h=[-1]*k
s=7
for i in range(k):
  m=s%k
  if h[0]==m:
    l=i+1
    break
  h[i]=m
  s=m*10+7
for i in range(l):
  if h[i]==0:
    print(i+1)
    break

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
import sys
k=int(input())
if k%2==0 or k%5==0:
  print(-1)
  sys.exit()
h=[-1]*k
s=7
for i in range(k):
  m=s%k
  if h[0]==m:
    l=i
    break
  h[i]=m
  s=m*10+7
for i in range(l):
  if h[i]==0:
    print(i+1)
    break

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
K = int(input())

seven = "7"

flag=0
for i in range(1,10000):
	if int(seven*i) % K == 0:
		print(i)
        flag=1
		break

if flag:
	print(-1)

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 and num % 5 != 0:
    
        if not 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:
k=int(input())
num=7%k
L=0
ans=-1


if k%7==0:
	L=(9*k)/7
else:
	L=9*k

if L%2==0 or L%5==0:
	ans=-1
else:
	for i in range(10**5):
		if (num*10)%L==1:
			ans=i
			break
		num=10**i %L
print(ans)

Submission status: Runtime Error

Solution code:
#include<bits/stdc++.h>
using namespace td;
using ll=long long int;
int main()
{
  ll mod,val;
  cin>>mod;
  val=7%mod;
  for(int i=1;i<1e7;i++)
  {
    if(val==0)
    {
      cout<<i<<endl;
      break;
    }
    val=(val*10+7)%mod;
  }
  cout<<"-1"<<endl;
}

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
from math import gcdnbv
K=int(input())
if K%7==0:
  K=K//7
if gcd(10,K)!=1:
  print(-1)
  return
x=1%K
cnt=1
while x!=0:
  x=(10*x+1)%K
  cnt+=1
print(cnt)

Submission status: Runtime Error

Solution code:
from math import gcd
K=int(input())
if K%7==0:
  K=K//7
if gcd(10,K)!=1:
  print(-1)
  retur
x=1%K
cnt=1
while x!=0:
  x=(10*x+1)%K
  cnt+=1
print(cnt)

Submission status: Runtime Error

Solution code:
from math import gcd
K=int(input())
if K%7==0:
  K=K//7
if gcd(10,K)!=1:
  print(-1)
  return
x=1%K
cnt=1
while x!=0:
  x=(10*x+1)%K
  cnt+=1
print(cnt)

Submission status: Runtime Error

Solution code:
int k = in.nextInt();
if (k % 7 == 0)
    k /= 7;

if (gcd(10, k) != 1) {
    out.println(-1);
    return;
}

long v = 1 % k;
int len = 1;
while (v != 0) {
    v = (10 * v + 1) % k;
    len++;
}

out.println(len);

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
from collections import defaultdict

k = int(input())

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

def f(k):
  if k % 2 == 0 or k % 5 == 0:
    return -1    

  val = 7
  cnt = 1
  while True:
    if val % k == 0:
      break
    cnt += 1
    val = val * 10 + 7
  return cnt
    
li = prime_factorize(k)

ans = 1
for k, v in li.items():
  if k <= 10000:
    ans *= f(k) ** v
  else:
    ans *= (l - 1) ** v
    
if ans < 0:
  print(-1)
else:
  print(ans)

Submission status: Runtime Error

Solution code:
vn = int(input())
cnt = 1
seven = 7

while cnt<n:
  if seven==0:
    print(cnt)
    exit()
  seven = (seven*10+7)%n
  cnt += 1
print(-1)

Submission status: Runtime Error

Solution code:
K = int(input())

ans = 1
X = 7
cnt = K
while ans <= K:
    x = X % K
    if rem == 0:
        print(ans)
        break
    else:
        ans += 1
        X = x*10 + 7 

if rem != 0:
    print(-1)

Submission status: Runtime Error

Solution code:
k = int(input())
seven = 7
count = 0

def main():
    for i in range(1000000):
        if k % 2 == 0:
            count = -1
            return

        elif seven % k == 0:
            count += 1
            print(count)
            return
        else:
            count += 1
            seven = seven * 10 + 7
    print(-1)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
K = int(input())

X = 10
ans = 1    
while ans <= L:
    L = 9*K/7
    x = X%L
    if x == 1:
        print(ans)
        break
    else:
        ans += 1
        X = x*10 

if x != 1:
    print(-1)

Submission status: Runtime Error

Solution code:
k = int(input())
seven = ７
count = 0

while True:
    if k % 2 == 0:
        count = -1
        break

    elif seven % k == 0:
        count += 1
        break
    else:
        count += 1
        seven = seven * 10 + 7

print(count)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
k = int(input())
x = 7%k
s = []

for i in range(k):
  if x == 0:
    print(len(i+1))
    exit()
  s.append(x)
  x = (10*x + 7)%k

  
  
print(-1)

Submission status: Runtime Error

Solution code:
k = int(input())
x = 7%k
s = []

for i in range(k):
  if x == 0:
    print(len(s+1))
    exit()
  s.append(x)
  x = (10*x + 7)%k

  
  
print(-1)

Submission status: Runtime Error

Solution code:
k = int(input())
b = 7
c = 1
a = []
e = 0
a.append(7)
if(k%2 == 0):
  print(-1)
else:
  while(b%k != 0):
    r = b%k
    b = 10*r+7
    c += 1
    if b in a:
      e = 1
  	a.append(b)
  if(e == 1):
    print(-1)
  else:
  	print(c)

Submission status: Runtime Error

Solution code:
k = int(input())
b = 7
c = 1
a = []
a.append(7)
if(k%2 == 0):
  print(-1)
else:
  while(b%k != 0):
    r = b%k
    b = 10*r+7
    c += 1
    if b in a:
      print(-1)
  	a.append(b)
  print(c)

Submission status: Runtime Error

Solution code:
k = int(input())
x = 7%k
s = []

while x not in s:
  if x == 0:
    print(len(s+1))
    break
  s.append(x)
  x = (10*x + 7)%k

  
if s[-1] != 0:
  print(-1)

Submission status: Runtime Error

Solution code:
k=int(input())

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

else:
    num=7%k
    ans=1

    while num != 0:

        num=(num*10+7)%k
        ans+=1

print(ans)

Submission status: Runtime Error

Solution code:
k = int(input())
x = 7%k
s = set()
while s.count(x) == 0:
  s.append(x)
  x = (10*x + 7)%k

if s[-1] == 0:
  print(len(s))
else:
  print(-1)

Submission status: Runtime Error

Solution code:
k = int(input())
x = 7%k
s = set()
while s.count(x) == 0:
  s.append(x)
  x = (10*x + 7)

Submission status: Runtime Error

Solution code:
a = 7
b = int(inout())

list = [7]
for i in range(b):
    list.append(list[-1]*10 +7)

for l in range(len(list)):
    if list[l] % b == 0:
        print(l+1)
        exit()

Submission status: Runtime Error

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

print(-1)

Submission status: Runtime Error

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

print(-1)

Submission status: Runtime Error

Solution code:
K = int(input())

X = 10
ans = 1

if 
while ans <= 9000000:
    x = X%(9*K)
    if x == 1:
        print(ans)
        break
    else:
        ans += 1
        X = x*10 

if x != 1:
    print(-1)

Submission status: Runtime Error

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