結果

問題 No.1310 量子アニーリング
ユーザー renjyaku_intrenjyaku_int
提出日時 2020-11-07 01:28:28
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 327 ms / 2,000 ms
コード長 1,925 bytes
コンパイル時間 2,781 ms
コンパイル使用メモリ 200,708 KB
実行使用メモリ 34,380 KB
最終ジャッジ日時 2023-09-29 19:55:46
合計ジャッジ時間 10,728 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 315 ms
34,148 KB
testcase_01 AC 317 ms
34,364 KB
testcase_02 AC 317 ms
34,292 KB
testcase_03 AC 315 ms
34,268 KB
testcase_04 AC 327 ms
34,380 KB
testcase_05 AC 319 ms
34,292 KB
testcase_06 AC 317 ms
34,292 KB
testcase_07 AC 303 ms
34,272 KB
testcase_08 AC 303 ms
34,224 KB
testcase_09 AC 308 ms
34,376 KB
testcase_10 AC 314 ms
34,208 KB
testcase_11 AC 324 ms
34,104 KB
testcase_12 AC 307 ms
34,268 KB
testcase_13 AC 313 ms
34,108 KB
testcase_14 AC 315 ms
34,040 KB
testcase_15 AC 327 ms
34,152 KB
testcase_16 AC 319 ms
34,264 KB
testcase_17 AC 314 ms
34,248 KB
testcase_18 AC 319 ms
34,152 KB
testcase_19 AC 314 ms
34,212 KB
testcase_20 AC 305 ms
34,252 KB
testcase_21 AC 310 ms
34,364 KB
testcase_22 AC 319 ms
34,156 KB
testcase_23 AC 323 ms
34,108 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1e9;
const double eps = 1e-7;
const ll LINF = ll(1e18);
const int MOD = 998244353;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
const long double pi = 4 * atan(1);
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll mpow(ll x, ll n)
{
    ll ans = 1;
    while (n != 0)
    {
        if (n & 1)
            ans = ans * x % MOD;
        x = x * x % MOD;
        n = n >> 1;
    }
    return ans;
}
vector<ll> fac(2000001);  //n!(mod M)
vector<ll> ifac(2000001); //k!^{M-2} (mod M)
ll comb(ll a, ll b)
{ //aCb(mod M)
    if (a == 0 && b == 0)
        return 1;
    if (a < b || a < 0)
        return 0;
    ll tmp = ifac[a - b] * ifac[b] % MOD;
    return tmp * fac[a] % MOD;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    assert(n <= 2 * pow(10, 5) && n >= 3);
    fac[0] = 1;
    ifac[0] = 1;
    for (ll i = 0; i < 2000000; i++)
    {
        fac[i + 1] = fac[i] * (i + 1) % MOD;              // n!(mod M)
        ifac[i + 1] = ifac[i] * mpow(i + 1, MOD - 2) % MOD; // k!^{M-2} (mod M)
    }
    ll ans=0;
    for(ll i=0;i<=n;i+=2){
        ans+=2*comb(n,i)*mpow(2,abs(n-2*i))%MOD;
        ans%=MOD;
    }
    cout<<ans<<"\n";
}
0