結果

問題 No.287 場合の数
ユーザー Shaik Mulla Abeed BashaShaik Mulla Abeed Basha
提出日時 2023-07-07 15:38:57
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 8,274 bytes
コンパイル時間 4,390 ms
コンパイル使用メモリ 359,176 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-28 16:13:30
合計ジャッジ時間 5,833 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <x86intrin.h>
#include <bits/stdc++.h>

using namespace std;

using str = string;
using ll = long long;
using ld = long double;
using u64 = unsigned long long;

template<class T>
using pr = pair<T, T>;
template<class T>
using vt = vector<T>;
template<class T>
using vvt = vector<vt<T>>;

#define ar array
#define pb push_back
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define len(x) (int)(x).size()
#define elif else if
#define def function

#define F_OR(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>(b); i+=(s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define rep(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define each(x, a) for (auto& x: a)
#define r_each(x,a) for(auto& x:a | views::reverse)

template<class T>
constexpr T inf = 0;
template<>
constexpr int inf<int> = 1'000'000'005;
template<>
constexpr long long inf<long long> = (long long) (inf<int>) * inf<int> * 2;
template<>
constexpr unsigned int inf<unsigned int> = inf<int>;
template<>
constexpr unsigned long long inf<unsigned long long> = inf<long long>;
template<>
constexpr __int128 inf<__int128> = __int128(inf<long long>) * inf<long long>;
template<>
constexpr double inf<double> = inf<long long>;
template<>
constexpr long double inf<long double> = inf<long long>;

template<class T, class S>
inline bool ctmax(T &a, const S &b) { return (a < b ? a = b, 1 : 0); }
template<class T, class S>
inline bool ctmin(T &a, const S &b) { return (a > b ? a = b, 1 : 0); }

template<typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {os << p.first << " " << p.second;return os;}
template<typename T, typename U>
istream &operator>>(istream &is, pair<T, U> &p) {is >> p.first >> p.second;return is;}
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {int s = (int) v.size();for (int i = 0; i < s; i++) os << (i ? " " : "") << v[i];return os;}
template<typename T>
istream &operator>>(istream &is, vector<T> &v) {for (auto &x: v) is >> x;return is;}
void read() {}
template<typename T, class... U>
void read(T &t, U &...u) {cin >> t;read(u...);}
void print() { cout << "\n"; }
template<typename T, class... U, char sep = ' '>
void print(const T &t, const U &...u) {cout << t;if (sizeof...(u)) cout << sep;print(u...);}
void write() { cout << " "; }
template<typename T, class... U, char sep = ' '>
void write(const T &t, const U &...u) {cout << t;if (sizeof...(u)) cout << sep;write(u...);}
#define Int(...)   \
  int __VA_ARGS__; \
  read(__VA_ARGS__)
#define Ll(...)   \
  long long __VA_ARGS__; \
  read(__VA_ARGS__)
#define Str(...)      \
  string __VA_ARGS__; \
  read(__VA_ARGS__)
#define Vt(type, name, size) \
  vector<type> name(size);    \
  read(name)
#define Die(...)             \
  do {                       \
    print(__VA_ARGS__); \
    return 0;                  \
  } while (0)

__attribute__((target("popcnt"))) inline int popcnt(const u64 &a) {
    return _mm_popcnt_u64(a);
}
inline int lsb(const u64 &a) { return a ? __builtin_ctzll(a) : 64; }
inline int ctz(const u64 &a) { return a ? __builtin_ctzll(a) : 64; }
inline int msb(const u64 &a) { return a ? 63 - __builtin_clzll(a) : -1; }
template<typename T>
inline int gbit(const T &a, int i) {
    return (a >> i) & 1;
}
template<typename T>
inline void sbit(T &a, int i, bool b) {
    if (gbit(a, i) != b) a ^= T(1) << i;
}
constexpr long long Pw(int n) { return 1LL << n; }
constexpr long long Msk(int n) { return (1LL << n) - 1; }

template<typename T>
vector<int> argsort(const vector<T> &A) {
    vector<int> ids((int) A.size());
    iota(ids.begin(), ids.end(), 0);
    sort(ids.begin(), ids.end(),
         [&](int i, int j) { return (A[i] == A[j] ? i < j : A[i] < A[j]); });
    return ids;
}

#define MIN(v) *min_element(all(v))
#define MAX(v) *max_element(all(v))
#define LB(c, x) distance((c).begin(), lower_bound(all(c), (x)))
#define UB(c, x) distance((c).begin(), upper_bound(all(c), (x)))
#define UNIQUE(x) \
  sort(all(x)), x.erase(unique(all(x)), x.end()), x.shrink_to_fit()

namespace dbg{
    // DEBUG BEGIN
#ifndef ONLINE_JUDGE
    template<class L, class R> ostream &operator<<(ostream &out, const pair<L, R> &p){
        return out << "{" << p.first << ", " << p.second << "}";
    }
    template<class Tuple, size_t N> struct _tuple_printer{
        static ostream &_print(ostream &out, const Tuple &t){ return _tuple_printer<Tuple, N-1>::_print(out, t) << ", " << get<N-1>(t); }
    };
    template<class Tuple> struct _tuple_printer<Tuple, 1>{
        static ostream &_print(ostream &out, const Tuple& t){ return out << get<0>(t); }
    };
    template<class... Args> ostream &_print_tuple(ostream &out, const tuple<Args...> &t){
        return _tuple_printer<decltype(t), sizeof...(Args)>::_print(out << "{", t) << "}";
    }
    template<class ...Args> ostream &operator<<(ostream &out, const tuple<Args...> &t){
        return _print_tuple(out, t);
    }
    template<class T> ostream &operator<<(class enable_if<!is_same<T, string>::value, ostream>::type &out, const T &arr){
        if(arr.empty()) return out << "{}";
        out << "{";
        for(auto it = arr.begin(); it != arr.end(); ++ it){
            out << *it;
            next(it) != arr.end() ? out << ", " : out << "}";
        }
        return out;
    }
    ostream &operator<<(ostream &out, const _Bit_reference &bit){
        return out << bool(bit);
    }
    template<class T, class A, class C>
    ostream &operator<<(ostream &out, priority_queue<T, A, C> pq){
        vector<T> a;
        while(!pq.empty()) a.push_back(pq.top()), pq.pop();
        return out << a;
    }
    template<class Head>
    void debug_out(Head H){ cerr << H << endl; }
    template<class Head, class... Tail>
    void debug_out(Head H, Tail... T){ cerr << H << ", ", debug_out(T...); }
    void debug2_out(){ }
    template<class Head, class... Tail>
    void debug2_out(Head H, Tail... T){ cerr << "\n"; for(auto x: H) cerr << x << ",\n"; debug2_out(T...); }
    template<class Width, class Head>
    void debugbin_out(Width w, Head H){
        for(auto rep = w; rep; -- rep, H >>= 1) cerr << (H & 1);
        cerr << endl;
    }
    template<class Width, class Head, class... Tail>
    void debugbin_out(Width w, Head H, Tail... T){
        for(auto rep = w; rep; -- rep, H >>= 1) cerr << (H & 1);
        cerr << ", "; debugbin_out(w, T...);
    }
    enum CODE{ CCRED = 31, CCGREEN = 32, CCYELLOW = 33, CCBLUE = 34, CCDEFAULT = 39 };
#define debug_endl() cerr << endl
#define debug(...) cerr << "\033[" << (int)CODE(CCRED) << "m[" << #__VA_ARGS__ << "]: \033[" << (int)CODE(CCBLUE) << "m", debug_out(__VA_ARGS__), cerr << "\33[" << (int)CODE(CCDEFAULT) << "m"
#define debug2(...) cerr << "\033[" << (int)CODE(CCRED) << "m[" << #__VA_ARGS__ << "] \033[" << (int)CODE(CCBLUE) << "m", debug2_out(__VA_ARGS__), cerr << "\33[" << (int)CODE(CCDEFAULT) << "m"
#define debugbin(...) cerr << "\033[" << (int)CODE(CCRED) << "m[" << #__VA_ARGS__ << "] \033[" << (int)CODE(CCBLUE) << "m", debugbin_out(__VA_ARGS__), cerr << "\33[" << (int)CODE(CCDEFAULT) << "m"
#else
    #define debug_endl() 42
    #define debug(...) 42
    #define debug2(...) 42
    #define debugbin(...) 42
#endif
    // DEBUG END
} using namespace dbg;

signed main() {
    cin.tie(0)->sync_with_stdio(0);
    cin.exceptions(ios::badbit | ios::failbit);

    auto __solve_tc = [&](auto __tc_num) -> int {
        Int(n);

        ll res=0;

        // calc 8c0 to 8c5

        rep(6){
            ll temp=1;
            vt<int> divides(8,1);
            rep(j,1,8){
                temp*=((6-i)*n-i+j);
                rep(j,1,8)
                    if(temp % j==0 && divides[j]) temp/=j,divides[j]=0;
            }
            ll te=1;
            rep(j,i) te*=(8-j);
            rep(j,i) te/=(j+1);
            debug(temp,te);
            if(i&1) res-=(temp*te);
            else res+=(temp*te);
        }

        print(res);
        return 0;
    };

    int __tc_cnt = 1;
//    cin >> __tc_cnt;
    for (auto __tc_num = 0; __tc_num < __tc_cnt; ++__tc_num) {
        __solve_tc(__tc_num);
    }
}
0