結果
| 問題 |
No.44 DPなすごろく
|
| ユーザー |
h_noson
|
| 提出日時 | 2016-02-16 12:04:58 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 583 bytes |
| コンパイル時間 | 545 ms |
| コンパイル使用メモリ | 67,392 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-22 07:16:36 |
| 合計ジャッジ時間 | 1,365 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 20 |
ソースコード
#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