結果
| 問題 | No.44 DPなすごろく |
| ユーザー |
h_noson
|
| 提出日時 | 2016-02-16 12:04:58 |
| 言語 | C++11 (gcc 15.3.0 + boost 1.92.0) |
| 結果 |
AC
不安定
|
| 実行時間 | 1 ms / 5,000 ms |
| + 453µs | |
| コード長 | 583 bytes |
| 記録 | |
| コンパイル時間 | 410 ms |
| コンパイル使用メモリ | 84,840 KB |
| 実行使用メモリ | 9,896 KB |
| 最終ジャッジ日時 | 2026-10-11 07:42:00 |
| 合計ジャッジ時間 | 1,839 ms |
|
ジャッジサーバーID (参考情報) |
judge4_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 21 |
ソースコード
#include <iostream>
#include <map>
using namespace std;
map<pair<int,int>,long long> combs;
long long combination(int n, int k) {
long long ret;
pair<int,int> p {n,k};
if (combs.count(p) == 0) {
if (k == 0 || k == n)
ret = 1;
else
ret = combination(n-1,k) + combination(n-1,k-1);
combs[p] = ret;
}
ret = combs[p];
return ret;
}
int main() {
int n;
cin >> n;
long long ans = 0;
for (int i = 0; i <= n/2; i++) {
ans += combination(n-i,i);
}
cout << ans << endl;
return 0;
}
h_noson