結果

問題 No.118 門松列(2)
ユーザー ty70ty70
提出日時 2015-06-01 02:09:32
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,958 bytes
コンパイル時間 709 ms
コンパイル使用メモリ 94,648 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-20 18:12:58
合計ジャッジ時間 1,847 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
権限があれば一括ダウンロードができます

ソースコード

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;

const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e2 + 2;

int c[MAX_N][MAX_N];

void init_comb (void ){
	memset (c, 0, sizeof (c ) );
	c[0][0] = 1;
	for (int i = 1; i < MAX_N; i++ ){
		rep (j, i+1 ){
			c[i-j][j] = (c[i-j][j] + (j     > 0 ? c[i-j][j-1] : 0 ) ) % MOD;
			c[i-j][j] = (c[i-j][j] + (i - j > 0 ? c[i-j-1][j] : 0 ) ) % MOD;
		} // end rep
	} // end for
}

int comb (int n, int m ){
	if (n < m ) return 0;
	return c[n-m][m];
}


int main()
{
	init_comb();
	ios_base::sync_with_stdio(0);
	int N; cin >> N;
	map<int,int> cnt; cnt.clear();
	rep (i, N ){
		int ain; cin >> ain;
		cnt[ain]++;
	} // end rep
	
	ll res = (ll)comb ((int)cnt.size(), 3 );
	map<int,int>::iterator it = cnt.begin();
	for (; it != cnt.end(); it++ ){
		int cc = (*it).second;
		map<int,int>::iterator jt = it;
		for (++jt; jt != cnt.end(); jt++ ){
			int dd = (*jt).second;
			map<int,int>::iterator kt = jt;
			for (++kt; kt != cnt.end(); kt++ ){
				int ee = (*kt).second;
				ll curr = (ll)(cc*dd*ee) % (ll)MOD;
				res = (res*curr ) % (ll)MOD;
			} // end for
		} // end for
	} // end for

	cout << res << endl;

	return 0;
}
0