結果

問題 No.44 DPなすごろく
ユーザー ku_material_ro
提出日時 2016-10-23 19:44:47
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
RE  
実行時間 -
コード長 613 bytes
コンパイル時間 741 ms
コンパイル使用メモリ 61,060 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-24 02:04:49
合計ジャッジ時間 2,483 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3 RE * 1
other AC * 5 WA * 10 RE * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
using namespace std;
int kaijo(long long n){
	long long ans = 1;
	if (n != 0){
		for (long long i = 0; i < n; i++){
			ans *= (n - i);
		}
	}
	else{
		ans = 1;
	}
	return ans;
}

int main(){
	long long n;
	long long cnt1 = 0;
	long long cnt2 = 0;
	long long cntp = 0;
	cin >> n;
	cnt2 = n / 2;
	if ((n / 2) * 2 == n){
		cnt1 = 0;
	}
	else{
		cnt1 = 1;
	}
	while (1){
		if (cnt2 == 0) {
			cntp += 1;
			break;
		}
		cntp += kaijo(cnt2 + cnt1) / (kaijo(cnt1)*kaijo(cnt2));
		cnt2 -= 1;
		cnt1 += 2;
	}
	cout << cntp << endl;
	return 0;
}
0