結果

問題 No.1531 く2
ユーザー 👑 NachiaNachia
提出日時 2021-06-04 21:24:03
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 853 bytes
コンパイル時間 604 ms
コンパイル使用メモリ 74,436 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-30 01:32:06
合計ジャッジ時間 1,916 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 WA -
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
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 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 AC 2 ms
5,376 KB
testcase_44 AC 2 ms
5,376 KB
testcase_45 AC 2 ms
5,376 KB
testcase_46 AC 2 ms
5,376 KB
testcase_47 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(int i=0; i<(n); i++)


const ll M = 998244353;

ll solve(ll K){
  if(K == 0) return 0;
  if(K == 1) return 1;
  int d=0; while((K>>(d+1)) != 0) d++;
  ll res = 1;
  rep(t,d) res = res * 3 % M;
  res += solve(K - (1ll << d)) * 2;
  res %= M;
  return res;
}

int main(){
  ll N, K; cin >> N >> K;
  ll ans = 0;
  if(N % 2 == 0){
    ans = solve(K/2+N/2+1);
    ans = ans + M - solve(K/2);
    ans %= M;
    if(K % 2 == 1) ans = ans * 2 % M;
  }
  else{
    ans = solve(K+N+1);
    ans = ans + M - solve(K);
    ans %= M;
  }
  cout << ans << "\n";
  return 0;
}



struct ios_do_not_sync{
  ios_do_not_sync(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
  }
} ios_do_not_sync_instance;


0