結果

問題 No.398 ハーフパイプ(2)
ユーザー sortreewsortreew
提出日時 2016-07-15 23:53:59
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 164 ms / 2,000 ms
コード長 1,212 bytes
コンパイル時間 2,010 ms
コンパイル使用メモリ 145,208 KB
実行使用メモリ 40,272 KB
最終ジャッジ日時 2023-09-09 22:03:15
合計ジャッジ時間 4,448 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,384 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 164 ms
40,204 KB
testcase_03 AC 164 ms
40,272 KB
testcase_04 AC 164 ms
40,204 KB
testcase_05 AC 66 ms
26,748 KB
testcase_06 AC 57 ms
23,048 KB
testcase_07 AC 123 ms
34,204 KB
testcase_08 AC 4 ms
4,380 KB
testcase_09 AC 91 ms
31,336 KB
testcase_10 AC 82 ms
29,664 KB
testcase_11 AC 62 ms
25,928 KB
testcase_12 AC 130 ms
36,840 KB
testcase_13 AC 126 ms
36,488 KB
testcase_14 AC 135 ms
37,516 KB
testcase_15 AC 34 ms
18,728 KB
testcase_16 AC 127 ms
36,452 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(int)(b);i++)
#define REP(i,b) FOR(i,0,b)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define TT second.second
#define SS second.first
#define FF first
using namespace std;
typedef long double ld;
typedef long long LL;
typedef int ut;
typedef vector<ut> VI;
typedef pair<ut,ut> pr;
typedef pair<ut,pr> ppr;
typedef vector<pr> Vpr;
typedef priority_queue<pr,Vpr,greater<pr> > PQ;
const int INF=1<<30;
const int BITSIZE=1<<12;
const int SIZE=10+2*1e4;
LL DP[101][101][5][400];
LL solve(int a,int b,int n,LL sum){
	if(n==0) return sum==0;
	if(n*b<sum) return 0;
	if(sum<n*a) return 0;
	if(DP[a][b][n][sum]) return DP[a][b][n][sum];
	LL answer=0;
	FOR(i,a,b+1)
		answer+=solve(a,b,n-1,sum-i);
	return DP[a][b][n][sum]=answer; 
}
LL nCrDP[100][100];
LL nCr(int n,int r){
	if(r==0 || r==n) return 1;
	if(nCrDP[n][r]) return nCrDP[n][r];
	return nCrDP[n][r]=nCr(n-1,r-1)+nCr(n-1,r);
}
int main(){
	ld x;
	cin >> x;
	LL sum=x*4;
	LL answer=0;
	REP(i,101)
		REP(j,i){
			FOR(k,1,5+1)
				FOR(l,1,6-k+1){
					answer+=nCr(6,k)*nCr(6-k,l)*solve(j+1,i-1,6-k-l,sum-i*(k-1)-j*(l-1));
					}
		}
	if(sum%4==0) answer++;
	cout << answer << endl;
	return 0;
}
0