結果

問題 No.73 helloworld
ユーザー data9824data9824
提出日時 2015-06-07 14:51:55
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,248 bytes
コンパイル時間 432 ms
コンパイル使用メモリ 58,500 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-11 11:25:40
合計ジャッジ時間 1,286 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <algorithm>

using namespace std;

unsigned long long combination(unsigned long long n, unsigned long long m) {
	if (n < m) {
		return 0;
	}
	unsigned long long smaller = min(m, n - m);
	unsigned long long larger = max(m, n - m);
	unsigned long long numerator = 1;
	for (unsigned long long x = n; x > larger; --x) {
		numerator *= x;
	}
	unsigned long long denominator = 1;
	for (unsigned long long x = smaller; x > 0; --x) {
		denominator *= x;
	}
	return numerator / denominator;
}

int main() {
	int c[26];
	for (int i = 0; i < 26; ++i) {
		cin >> c[i];
	}
	unsigned long long maxCount = 0;
	for (int formerL = 2; formerL < c['l' - 'a']; ++formerL) {
		for (int formerO = 1; formerO < c['o' - 'a']; ++formerO) {
			unsigned long long count = 1;
			count *= combination(c['h' - 'a'], 1);
			count *= combination(c['e' - 'a'], 1);
			count *= combination(formerL, 2);
			count *= combination(formerO, 1);
			count *= combination(c['w' - 'a'], 1);
			count *= combination(c['o' - 'a'] - formerO, 1);
			count *= combination(c['r' - 'a'], 1);
			count *= combination(c['l' - 'a'] - formerL, 1);
			count *= combination(c['d' - 'a'], 1);
			maxCount = max(maxCount, count);
		}
	}
	cout << maxCount << endl;
	return 0;
}
0