結果

問題 No.73 helloworld
ユーザー ty70ty70
提出日時 2015-06-08 05:47:42
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,773 bytes
コンパイル時間 728 ms
コンパイル使用メモリ 95,312 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-20 19:45:41
合計ジャッジ時間 1,514 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 WA -
testcase_06 AC 2 ms
4,376 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 1 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['r'], 1 );
	res *= comb (cnt['d'], 1 );
	
	if (cnt['l'] != 3 ){
		ll curr = 0LL;
		for (int sum = 2; sum <= cnt['l'] - 1; sum++ ){
			curr = max (curr, comb (sum, 2 )*comb (cnt['l'] - sum, 1 ) );
		} // end for
		res *= curr;
	} // end if

	if (cnt['o'] != 2 ){
		ll curr = 0LL;
		for (int sum = 1; sum <= cnt['o'] - 1; sum++ ){
			curr = max (curr, comb (sum, 1 )*comb (cnt['o'] - sum, 1 ) );
		} // end for
		res *= curr;
	} // end if
	
	cout << res << endl;		

	return 0;
}
0