結果

問題 No.118 門松列(2)
ユーザー codershifthcodershifth
提出日時 2015-09-04 09:52:11
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 12 ms / 5,000 ms
コード長 3,313 bytes
コンパイル時間 1,481 ms
コンパイル使用メモリ 162,088 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-17 13:07:20
合計ジャッジ時間 2,501 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int (i)=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define RANGE(vec) (vec).begin(),(vec).end()

using namespace std;

class ModInt {
    long long value_;

public:
    static long long Mod;
    static void set_mod(long long mod) { Mod= mod; }
    static long long  get_mod(void) { return Mod; }

    ModInt() : value_(0) {}
    ModInt(long long val) {
            if (val >= Mod)
                value_ = val % Mod;
            else if (val >= 0)
                value_ = val;
            else // val < 0
                value_ = (((-val)/Mod+1)*Mod+val) % Mod;
            assert(value_ < Mod);
    }
    ModInt(const ModInt &other) { value_ = other.value_; }
    ~ModInt() {}

#define OPT(OP)                                                         \
    ModInt operator OP (const ModInt &other) const {                    \
        return ModInt(value_ OP other.value_);                          \
    }                                                                   \
    template<class T>                                                   \
    ModInt &operator OP##=(const T &other) {                            \
        return (*this = (*this OP ModInt(other)));                      \
    }
    OPT(+) OPT(-) OPT(*)
#undef OPT

    bool operator==(const ModInt &other) const {
        return (value_ == other.value_);
    }
    bool operator!=(const ModInt &other) const {
        return !(*this == other);
    }
    ModInt &operator=(const ModInt &other) {
        value_ = other.value_;
        return *this;
    }

    // cast overload
    operator int() const { return value_; }
    operator long long() const { return value_; }
    static long long pow(ModInt a, int k) {
        ModInt  b = 1;
        while (k > 0)
        {
            if (k & 1)
                b = (b*a);
            a = (a*a);
            k >>= 1;
        }
        return b;
    }
    // call when Mod is prime
    ModInt inv() { return ModInt::pow(*this, Mod-2); }
    long long value() const { return value_; }
    friend std::ostream& operator<<(std::ostream& os, const ModInt& m) {
        os<<m.value_;
        return os;
    }
};
// 互換性サポートは int, long long のみ
#define OPT(OP,T)                                                        \
    ModInt operator OP (const ModInt &a, T b) { return a OP ModInt(b); } \
    ModInt operator OP (T a, const ModInt &b) { return ModInt(a) OP b; }
    OPT(*,int) OPT(+,int) OPT(-,int) OPT(*,long long) OPT(+,long long) OPT(-,long long)
#undef  OPT

long long ModInt::Mod = (long long)(1E+9)+7;

class PineDecorationSequence2 {
public:
    void solve(void) {
            int N;
            cin>>N;

            vector<int> cntA(101,0);
            REP(i,N)
            {
                int a;
                cin>>a;
                ++cntA[a];
            }

            ModInt all = 0;
            REP(i,101)
            FOR(j,i+1,101)
            FOR(k,j+1,101)
                all += ModInt(cntA[i])*cntA[j]*cntA[k];
            cout<<all<<endl;
    }
};

#if 1
int main(int argc, char *argv[])
{
        ios::sync_with_stdio(false);
        auto obj = new PineDecorationSequence2();
        obj->solve();
        delete obj;
        return 0;
}
#endif
0