Created
February 21, 2021 11:47
This is my code of Problem C of AtCoder Beginner Contest 174.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 入力 | |
K = int(input()) | |
# 7, 77, 777, ……を順番に格納していく変数aの初期化 | |
a = 0 | |
# 高々K回確認すればよい | |
for i in range(K): | |
# aの末尾に7を追加 | |
# 数字が大きくなりすぎるのを防ぐために, ここで7で割った剰余にしておく | |
a = (10*a + 7) % K | |
# 7で割った剰余が0かどうかを確認 | |
if a == 0: | |
# 答えの出力 | |
print(i + 1) | |
exit() | |
# 存在しなければ-1を出力 | |
print(-1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment