結果
問題 | No.420 mod2漸化式 |
ユーザー | ヒッキープログラミングするスレ |
提出日時 | 2016-09-10 00:19:43 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 35 ms / 1,000 ms |
コード長 | 735 bytes |
コンパイル時間 | 103 ms |
コンパイル使用メモリ | 12,288 KB |
実行使用メモリ | 10,624 KB |
最終ジャッジ日時 | 2024-12-24 11:23:36 |
合計ジャッジ時間 | 2,452 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 35 |
ソースコード
def f(n): if n == 0: return 0 else: return f(n // 2) + (n % 2) def test(n, r): for i in range(n, n + r): print(i, '{0:b}'.format(i).count('1'), f(i)) memo = {} def combi(n, r): if (n, r) in memo: return memo[(n, r)] elif n == 0: return 1 elif r == 0: return 1 elif n == r: return 1 else: x = combi(n - 1, r) + combi(n - 1, r - 1) memo[(n, r)] = x return x x = int(input()) if x == 0: print(1, 0) elif x > 31: print(0, 0) else: ans_count = combi(31, x) ans_sum = 0 multi = combi(30, x - 1) for i in range(31): t = 1 << i ans_sum += t * multi print(ans_count, ans_sum)