結果
問題 |
No.420 mod2漸化式
|
ユーザー |
![]() |
提出日時 | 2020-01-28 13:03:12 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 31 ms / 1,000 ms |
コード長 | 448 bytes |
コンパイル時間 | 169 ms |
コンパイル使用メモリ | 12,416 KB |
実行使用メモリ | 10,624 KB |
最終ジャッジ日時 | 2024-09-15 13:05:10 |
合計ジャッジ時間 | 2,697 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 35 |
ソースコード
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines from functools import lru_cache @lru_cache(None) def solve(N, x): if N == 0: if x == 0: return 1, 0 else: return 0, 0 c1, s1 = solve(N//2, x) c2, s2 = solve((N-1)//2, x-1) return c1 + c2, s1*2 + s2*2 + c2 N = 2 ** 31 - 1 x = int(read()) answer = solve(N, x) print(*answer)