結果
問題 | No.747 循環小数N桁目 Hard |
ユーザー |
![]() |
提出日時 | 2025-03-20 21:06:52 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 42 ms / 2,000 ms |
コード長 | 650 bytes |
コンパイル時間 | 237 ms |
コンパイル使用メモリ | 82,636 KB |
実行使用メモリ | 65,980 KB |
最終ジャッジ日時 | 2025-03-20 21:07:02 |
合計ジャッジ時間 | 7,843 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 120 |
ソースコード
n_str = input().strip()k_str = input().strip()# Step 1: Compute N mod 6a = 0for c in n_str:a = (a * 10 + int(c)) % 6# Step 2: Determine if K is even or odd (K mod 2)k_parity = int(k_str[-1]) % 2 if k_str else 0# Step 3: Determine remainder based on a and k_parityremainder = 0if a == 0:remainder = 0elif a == 1:remainder = 1elif a == 2:remainder = 2 if k_parity else 4elif a == 3:remainder = 3elif a == 4:remainder = 4elif a == 5:remainder = 5 if k_parity else 1# Mapping remainders to their respective digits in the cycle "285714"digits_order = [4, 2, 8, 5, 7, 1]print(digits_order[remainder])