結果

問題 No.118 門松列(2)
ユーザー kpinkcatkpinkcat
提出日時 2023-10-25 16:18:29
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 22 ms / 5,000 ms
コード長 1,230 bytes
コンパイル時間 2,323 ms
コンパイル使用メモリ 204,456 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-25 16:18:33
合計ジャッジ時間 3,491 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,348 KB
testcase_01 AC 21 ms
4,348 KB
testcase_02 AC 21 ms
4,348 KB
testcase_03 AC 22 ms
4,348 KB
testcase_04 AC 21 ms
4,348 KB
testcase_05 AC 21 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 20 ms
4,348 KB
testcase_10 AC 9 ms
4,348 KB
testcase_11 AC 10 ms
4,348 KB
testcase_12 AC 8 ms
4,348 KB
testcase_13 AC 6 ms
4,348 KB
testcase_14 AC 21 ms
4,348 KB
testcase_15 AC 6 ms
4,348 KB
testcase_16 AC 14 ms
4,348 KB
testcase_17 AC 6 ms
4,348 KB
testcase_18 AC 10 ms
4,348 KB
testcase_19 AC 13 ms
4,348 KB
testcase_20 AC 13 ms
4,348 KB
testcase_21 AC 18 ms
4,348 KB
testcase_22 AC 9 ms
4,348 KB
testcase_23 AC 16 ms
4,348 KB
testcase_24 AC 9 ms
4,348 KB
testcase_25 AC 12 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<list>
#include<queue>
#include<math.h>
#include<bitset>
using ll = long long;
using namespace std;

ll mod = 1e9+7;

uintmax_t combination(unsigned int n, unsigned int r) {
  if ( r * 2 > n ) r = n - r;
  uintmax_t dividend = 1;
  uintmax_t divisor  = 1;
  for ( unsigned int i = 1; i <= r; ++i ) {
    dividend *= (n-i+1);
    dividend %= mod;
    divisor  *= i;
  }
  return dividend / divisor;
}

int main(){
    int n;
    ll cnt = 0, mul = 1, ans = 0;
    cin >> n;
    vector<int> v(101), v1;
    for (int i = 0; i < n; i++) {
        int t;
        cin >> t;
        v[t]++;
    }
    for (int i = 1; i < 101; i++){
        if (v[i]) {
            v1.push_back(i);
            cnt++;
        }
    }
    if (cnt >= 3){
        for (int i = 0; i < v1.size()-2; i++){
            for (int j = i+1; j < v1.size()-1; j++){
                for (int k = j+1; k < v1.size(); k++){
                    ans += v[v1[i]]*v[v1[j]]%mod*v[v1[k]]%mod;
                    ans %= mod;
                }
            }
        }
    }
    if (cnt < 3) cout << 0 << endl;
    else cout << ans << endl;
}
0