結果
| 問題 | No.73 helloworld |
| コンテスト | |
| ユーザー |
ty70
|
| 提出日時 | 2015-06-08 06:07:41 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 1,764 bytes |
| コンパイル時間 | 853 ms |
| コンパイル使用メモリ | 96,484 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-29 02:03:30 |
| 合計ジャッジ時間 | 1,415 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 14 |
ソースコード
#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;
}
ty70