結果

問題 No.118 門松列(2)
コンテスト
ユーザー hotpepsi
提出日時 2015-01-09 00:31:28
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 775 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 521 ms
コンパイル使用メモリ 88,272 KB
実行使用メモリ 7,720 KB
最終ジャッジ日時 2026-03-05 23:37:52
合計ジャッジ時間 1,574 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 4 WA * 22
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <iostream>
#include <algorithm>
#include <sstream>
#include <vector>

using namespace std;

typedef long long LL;

#define COMBSZ 120
#define MOD 1000000007LL

int main(int argc, char *argv[])
{
	LL C[COMBSZ][COMBSZ] = { 1 };		// should be static for larger size
	for (LL i = 1; i < COMBSZ; ++i) {
		C[i][0] = 1;
		for (LL j = 1; j <= i; ++j) {
			C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % MOD;
		}
	}

	string s;
	getline(cin, s);
	int N = atoi(s.c_str());
	getline(cin, s);
	stringstream ss(s);
	int cnt[102] = {};
	int t = 0;
	for (LL i = 0; i < N; ++i) {
		int n;
		ss >> n;
		cnt[n] += 1;
		t += cnt[n] == 1;
	}

	LL ans = C[t][3];
	for (LL i = 1; i <= 100; ++i) {
		if (cnt[i] > 0) {
			ans = (ans * cnt[i]) % MOD;
		}
	}

	cout << ans << endl;
	return 0;
}
0