結果
問題 |
No.2193 メガの下1桁
|
ユーザー |
![]() |
提出日時 | 2025-04-16 16:30:53 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,329 bytes |
コンパイル時間 | 531 ms |
コンパイル使用メモリ | 82,076 KB |
実行使用メモリ | 53,944 KB |
最終ジャッジ日時 | 2025-04-16 16:32:50 |
合計ジャッジ時間 | 3,317 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 33 WA * 7 |
ソースコード
def compute_next(current, D_mod, B): base = (current + D_mod) % B exponent = current if base == 0 and exponent == 0: return 1 % B return pow(base, exponent, B) M = int(input()) D = int(input()) N = int(input()) B = int(input()) D_mod = D % B current = M % B if N == 0: res = current else: history = [current] # history[0] is the initial value (0 applications) # Apply the first transformation current = compute_next(current, D_mod, B) history.append(current) # history[1] is after 1 application found = False for i in range(1, N): # We need to apply N transformations in total next_val = compute_next(current, D_mod, B) if next_val in history: start_idx = history.index(next_val) cycle = history[start_idx:] cycle_len = len(cycle) remaining = N - (i + 1) # remaining steps after i+1 transformations if remaining <= 0: res = next_val else: pos = remaining % cycle_len res = cycle[pos] found = True break history.append(next_val) current = next_val if not found: res = current # after N transformations # Convert res to B-based digit if res < 10: print(res) else: print('A')