結果

問題 No.73 helloworld
ユーザー ty70ty70
提出日時 2015-06-08 06:07:41
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,764 bytes
コンパイル時間 781 ms
コンパイル使用メモリ 94,516 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-11 11:25:44
合計ジャッジ時間 1,583 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

ll comb (int n, int r ){
	
	if (n == 0 || r == 0 ) return 0LL;

	if (n < r ) return 0LL;
	if (n - r < r ) r = n - r;

	ll res = 1LL;
	rep (i, r )
		res *= (ll)n, n--;
	rep (i, r )
		res /= (ll)(i+1LL);
		
	return res;
}

int main()
{
	ios_base::sync_with_stdio(0);
	map<char,int> cnt; cnt.clear();
	int in;
	rep (i, 26 ) cin >> in , cnt[(char)('a' + i ) ] = in;

	ll res = 1LL;
	res *= comb (cnt['h'], 1 );
	res *= comb (cnt['e'], 1 );
	res *= comb (cnt['w'], 1 );
	res *= comb (cnt['r'], 1 );
	res *= comb (cnt['d'], 1 );

	ll currl = 0LL, curro = 0LL, curr = 0LL;
	for (int suml = 2; suml < cnt['l']; suml++ ){
			currl = max (currl, comb (suml, 2 )*comb (cnt['l'] - suml, 1 ) );
			for (int sumo = 1; sumo < cnt['o']; sumo++ ){
				curro = max (curro, comb (sumo, 1 )*comb (cnt['o'] - sumo, 1 ) );
				curr  = max (curr, currl*curro );
			} // end for
	} // end for
	res *= curr;

	cout << res << endl;		

	return 0;
}
0