結果

問題 No.118 門松列(2)
ユーザー temp
提出日時 2015-01-19 20:05:44
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 1,168 bytes
コンパイル時間 711 ms
コンパイル使用メモリ 76,568 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-06-22 19:07:11
合計ジャッジ時間 2,129 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 3 WA * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <functional>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cctype>
#include <string>
#include <cstring>

using namespace std;

typedef long long ll;

#define MODN 1000000007

ll expoModN(ll a, ll b) {
  if (b == 1) return a;
  if (b == 0) return 1;
  ll t = (expoModN(a, b/2)%MODN);
  return (((t*t)%MODN)*(expoModN(a, b%2)%MODN))%MODN;
}

ll combiModN(ll a, ll b) {
  ll ta = 1;
  for (ll i = 0; i < b; i++) ta = (ta*(a--))%MODN;
  ll tb = 1;
  while (b) tb = (tb*(b--))%MODN;
  return (ta*expoModN(tb,MODN-2))%MODN;
}

int main() {
  ll n;
  cin >> n;
  ll a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int memo[101];
  memset(memo, 0, sizeof(memo));
  sort(a, a+n);
  vector <ll> t;
  t.push_back(a[0]);
  for (int i = 1; i < n; i++) {
    memo[a[i]]++;
    if (t[int(t.size())-1] != a[i]) {
      t.push_back(a[i]);
    }
  }
  ll x = t.size();
  ll ans = combiModN(x, 3);
  for (int i = 0; i < 101; i++) {
    if (!memo[i]) continue;
    ans = (ans*memo[i])%MODN;
  }

  cout << ans << endl;
}
0