Skip to content

Instantly share code, notes, and snippets.

@Shinoryo
Created February 21, 2021 11:47
This is my code of Problem C of AtCoder Beginner Contest 174.
# 入力
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