結果

問題 No.986 Present
ユーザー ngtkanangtkana
提出日時 2020-02-11 15:29:07
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 7,167 bytes
コンパイル時間 1,704 ms
コンパイル使用メモリ 173,176 KB
実行使用メモリ 6,548 KB
最終ジャッジ日時 2024-04-08 15:26:43
合計ジャッジ時間 3,145 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#define DEBUG 1
#include <bits/stdc++.h>
#define loop(n) for (lint ngtkana_is_a_genius = 0; ngtkana_is_a_genius < lint(n); ngtkana_is_a_genius++)
#define rep(i, begin, end) for (lint i = lint(begin); (i) < lint(end); i++)
#define all(v) v.begin(), v.end()
#define rand(l, r) std::uniform_int_distribution<>(l, r)(mt)
using lint = long long;
auto mt = std::mt19937_64(std::random_device{}());
auto cmn = [](auto&& pow2, auto b){ if (pow2 > b) {pow2 = b; return true;} return false; };
auto cmx = [](auto&& pow2, auto b){ if (pow2 < b) {pow2 = b; return true;} return false; };
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#if DEBUG
#define debug(...)\
    do {\
        std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
        debug_impl(__VA_ARGS__);\
        std::cerr << std::noboolalpha;\
    } while (false)
#else
#define debug(...) {}
#endif

template <typename T>
T inverse(T pow2, T m) {
    T u = 0, v = 1;
    while (pow2 != 0) {
        T t = m / pow2;
        m -= t * pow2; std::swap(pow2, m);
        u -= t * v; std::swap(u, v);
    }
    assert(m == 1);
    return u;
}
template <typename T>
class modular {
    private:
        int value;
    public:
        constexpr modular() = default;
        constexpr modular(const modular&) = default;
        constexpr modular(modular&&) = default;
        modular& operator=(const modular&) = default;
        modular& operator=(modular&&) = default;

        template <typename U>
        modular (const U& x) {value = normalize(x);}

        template <typename U>
        static auto normalize(const U& x) {
            int v = static_cast<int>(-mod() <= x && x < mod() ? x : x % mod());
            if (v < 0) v += mod();
            return v;
        }

        auto const& operator()() const { return value; }
        template <typename U>
        explicit operator U() const { return static_cast<U>(value); }
        constexpr static auto mod() { return T::value; }

        auto& operator+=(const modular& other) {
            if ((value += other.value) >= mod()) value -= mod();
            return *this;
        }
        auto& operator-=(const modular& other) {
            if ((value -= other.value) < 0) value += mod();
            return *this;
        }
        template <typename U>
        auto& operator+=(const U& other) {return *this += modular(other); }
        template <typename U>
        auto& operator-=(const U& other) {return *this -= modular(other); }
        auto operator-() const { return modular(-value); }
        auto& operator++() {return *this += 1;}
        auto& operator--() {return *this -= 1;}
        auto    operator++(int) {modular result(*this); operator++(); return result;}
        auto    operator--(int) {modular result(*this); operator--(); return result;}

        template <typename U = T>
        auto& operator*=(const modular& rhs) {
            value = normalize(static_cast<int64_t>(value) * static_cast<int64_t>(rhs.value));
            return *this;
        }
        auto& operator/=(const modular& other) {
            return *this *= modular(inverse(other.value, mod()));
        }
};
template <typename T> struct is_modular : std::false_type {};
template <typename T> struct is_modular <modular<T>> : std::true_type{};
template <typename T> constexpr bool is_modular_v = is_modular<T>::value;

template <typename T> bool operator==(const modular<T>& lhs, const modular<T>& rhs) { return lhs() == rhs(); }
template <typename T, typename U> bool operator==(const modular<T>& lhs, U rhs) { return lhs == modular<T>(rhs); }
template <typename T, typename U> bool operator==(U lhs, const modular<T>& rhs) { return modular<T>(lhs) == rhs; }

template <typename T> bool operator!=(const modular<T>& lhs, const modular<T>& rhs) { return !(lhs == rhs); }
template <typename T, typename U> bool operator!=(const modular<T>& lhs, U rhs) { return !(lhs == rhs); }
template <typename T, typename U> bool operator!=(U lhs, const modular<T>& rhs) { return !(lhs == rhs); }

template <typename T> modular<T> operator+(const modular<T>& lhs, const modular<T>& rhs) { return modular<T>(lhs) += rhs; }
template <typename T, typename U> modular<T> operator+(const modular<T>& lhs, U rhs) { return modular<T>(lhs) += rhs; }
template <typename T, typename U> modular<T> operator+(U lhs, const modular<T>& rhs) { return modular<T>(lhs) += rhs; }

template <typename T> modular<T> operator-(const modular<T>& lhs, const modular<T>& rhs) { return modular<T>(lhs) -= rhs; }
template <typename T, typename U> modular<T> operator-(const modular<T>& lhs, U rhs) { return modular<T>(lhs) -= rhs; }
template <typename T, typename U> modular<T> operator-(U lhs, const modular<T>& rhs) { return modular<T>(lhs) -= rhs; }

template <typename T> modular<T> operator*(const modular<T>& lhs, const modular<T>& rhs) { return modular<T>(lhs) *= rhs; }
template <typename T, typename U> modular<T> operator*(const modular<T>& lhs, U rhs) { return modular<T>(lhs) *= rhs; }
template <typename T, typename U> modular<T> operator*(U lhs, const modular<T>& rhs) { return modular<T>(lhs) *= rhs; }

template <typename T> modular<T> operator/(const modular<T>& lhs, const modular<T>& rhs) { return modular<T>(lhs) /= rhs; }
template <typename T, typename U> modular<T> operator/(const modular<T>& lhs, U rhs) { return modular<T>(lhs) /= rhs; }
template <typename T, typename U> modular<T> operator/(U lhs, const modular<T>& rhs) { return modular<T>(lhs) /= rhs; }

template<typename T, typename U>
modular<T> power (const modular<T>& pow2, U b) {
    assert(b >= 0);
    modular<T> x = pow2, ret = 1;
    for (; b > 0; b /= 2) {
        if (b % 2 == 1) ret *= x;
        x *= x;
    }
    return ret;
}

template <typename T>
std::string to_string(const modular<T>& pow2) {
    return std::to_string(pow2());
}
template <typename T>
auto operator<<(std::ostream& os, const T& pow2)
    -> std::enable_if_t<is_modular_v<T>, std::ostream&>{
        return os << pow2();
    }
template <typename T>
auto operator>>(std::istream& is, T& pow2)
    -> std::enable_if_t<is_modular_v<T>, std::istream&> {
    long long x; is >> x;
    pow2 = T(x);
    return is;
}

// using mod_type = int;

// struct variable_mod { static mod_type value; };
// mod_type variable_mod::value;
// mod_type& mod = variable_mod::value;
// using mint = modular< variable_mod >;

constexpr int mod = 998244353;
using mint = modular<std::integral_constant<std::decay_t<decltype(mod)>, mod>>;

int main() {
    std::cin.tie(0); std::cin.sync_with_stdio(false);
    lint n, m; std::cin >> n >> m;
    std::vector<mint>pow2(n+m+1);
    pow2.at(0)=1;
    for(std::size_t i=1;i<pow2.size();i++){
        pow2.at(i)=pow2.at(i-1)*2;
    }


    mint ans0=power(mint{2},n);
    mint ans1=1;
    for(int i=0;i<n;i++){
        ans1*=pow2.at(m)-pow2.at(i);
        ans1/=pow2.at(n)-pow2.at(i);
    }

    mint ans2=1;
    for(int i=0;i<n;i++){
        ans2*=pow2.at(m)-pow2.at(i);
    }

    std::cout << ans0
        << " " << ans1
        << " " << ans2 << std::endl;
    return 0;
}
0