結果
問題 | No.118 門松列(2) |
ユーザー |
![]() |
提出日時 | 2015-07-23 04:11:08 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 59 ms / 5,000 ms |
コード長 | 3,157 bytes |
コンパイル時間 | 1,400 ms |
コンパイル使用メモリ | 162,088 KB |
実行使用メモリ | 11,008 KB |
最終ジャッジ日時 | 2024-10-09 07:05:53 |
合計ジャッジ時間 | 3,831 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 26 |
ソースコード
#include <bits/stdc++.h> using namespace std; namespace arithmetic { template<typename T> class Addition { public: template<typename V> T operator+(const V& v) const { return T(static_cast<const T&>(*this)) += v; } }; template<typename T> class Subtraction { public: template<typename V> T operator-(const V& v) const { return T(static_cast<const T&>(*this)) -= v; } }; template<typename T> class Multiplication { public: template<typename V> T operator*(const V& v) const { return T(static_cast<const T&>(*this)) *= v; } }; template<typename T> class Division { public: template<typename V> T operator/(const V& v) const { return T(static_cast<const T&>(*this)) /= v; } }; template<typename T> class Modulus { public: template<typename V> T operator%(const V& v) const { return T(static_cast<const T&>(*this)) %= v; } }; } template<typename T> class IndivisibleArithmetic : public arithmetic::Addition<T>, public arithmetic::Subtraction<T>, public arithmetic::Multiplication<T> {}; template<typename T> class Arithmetic : public IndivisibleArithmetic<T>, public arithmetic::Division<T> {}; class Inverse { private: long long mod; vector<long long> inv; public: Inverse() {} Inverse(long long mod, long long n = 1000000) : mod(mod) { inv = vector<long long>(n, 1); for (int i = 2; i < n; ++i) inv[i] = inv[mod % i] * (mod - mod / i) % mod; } long long operator()(long long a) const { if (a < (int)inv.size()) return inv[a]; long long b = mod, x = 1, y = 0; while (b) { long long t = a / b; swap(a -= t * b, b); swap(x -= t * y, y); } return (x %= mod) < 0 ? x + mod : x; } }; class Mint : public Arithmetic<Mint> { private: static long long mod; static Inverse inverse; long long val; public: Mint() {} Mint(const long long& val) { this->val = val % mod; if (this->val < 0) this->val += mod; } static void setMod(const long long& m) { mod = m; inverse = Inverse(m); } Mint operator+=(const Mint& m) { val += m.val; if (val >= mod) val -= mod; return *this; } Mint operator-=(const Mint& m) { val -= m.val; if (val < 0) val += mod; return *this; } Mint operator*=(const Mint& m) { val *= m.val; val %= mod; return *this; } Mint operator/=(const Mint& m) { val *= inverse(m.val); val %= mod; return *this; } Mint operator++() {return val += 1;} operator long long() { return val; } Mint identity() const { return 1; } }; long long Mint::mod = 1000000007; Inverse Mint::inverse(1000000007); ostream& operator<<(ostream& os, Mint a) { os << (long long)a; return os; } istream& operator>>(istream& is, Mint& a) { long long n; is >> n; a = n; return is; } int main() { int n; cin >> n; long long s[100] = {}; for (int i = 0; i < n; ++i) { int a; cin >> a; ++s[a - 1]; } Mint res = 0; for (int i = 0; i < 100; ++i) { for (int j = i + 1; j < 100; ++j) { for (int k = j + 1; k < 100; ++k) { res += s[i] * s[j] * s[k]; } } } cout << res << endl; }