結果

問題 No.746 7の倍数
ユーザー lloyzlloyz
提出日時 2022-05-16 00:33:43
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 16 ms / 2,000 ms
コード長 398 bytes
コンパイル時間 236 ms
コンパイル使用メモリ 10,828 KB
実行使用メモリ 8,308 KB
最終ジャッジ日時 2023-10-11 14:19:06
合計ジャッジ時間 2,203 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
8,072 KB
testcase_01 AC 15 ms
7,784 KB
testcase_02 AC 15 ms
7,764 KB
testcase_03 AC 15 ms
8,204 KB
testcase_04 AC 15 ms
7,792 KB
testcase_05 AC 15 ms
7,788 KB
testcase_06 AC 15 ms
8,244 KB
testcase_07 AC 15 ms
7,784 KB
testcase_08 AC 15 ms
8,300 KB
testcase_09 AC 16 ms
7,788 KB
testcase_10 AC 15 ms
7,796 KB
testcase_11 AC 15 ms
8,156 KB
testcase_12 AC 16 ms
8,208 KB
testcase_13 AC 15 ms
8,192 KB
testcase_14 AC 15 ms
8,256 KB
testcase_15 AC 15 ms
8,216 KB
testcase_16 AC 14 ms
8,144 KB
testcase_17 AC 15 ms
8,220 KB
testcase_18 AC 15 ms
8,308 KB
testcase_19 AC 15 ms
8,192 KB
testcase_20 AC 15 ms
8,200 KB
testcase_21 AC 15 ms
7,848 KB
testcase_22 AC 15 ms
8,220 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())

if n == 0:
    print(0)
    exit()

Q = []
R = []
curr = 10
nc = n
while nc > 0:
    q, r = divmod(curr, 7)
    if R and R[0] == r:
        break
    Q.append(q)
    R.append(r)
    curr = r * 10
    nc -= 1
if nc == 0:
    print("0." + ''.join(map(str, Q)))
else:
    loop = len(Q)
    q, r = divmod(n, loop)
    print("0." + ''.join(map(str, Q)) * q + ''.join(map(str, Q[:r])))
0