結果

問題 No.1531 く2
ユーザー SSRSSSRS
提出日時 2021-06-04 21:04:08
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 623 bytes
コンパイル時間 1,876 ms
コンパイル使用メモリ 168,640 KB
実行使用メモリ 4,512 KB
最終ジャッジ日時 2023-08-12 10:43:27
合計ジャッジ時間 2,975 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 1 ms
4,384 KB
testcase_02 AC 1 ms
4,384 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 2 ms
4,384 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 WA -
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,380 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 1 ms
4,380 KB
testcase_44 AC 1 ms
4,380 KB
testcase_45 AC 1 ms
4,380 KB
testcase_46 AC 2 ms
4,384 KB
testcase_47 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
const int LOG = 61;
const long long MOD = 998244353;
long long f(long long N){
  vector<vector<long long>> dp(LOG + 1, vector<long long>(2, 0));
  dp[LOG][0] = 1;
  for (int i = LOG - 1; i >= 0; i--){
    int d = N >> i & 1;
    if (d == 0){
      dp[i][0] += dp[i + 1][0];
      dp[i][1] += dp[i + 1][1] * 3;
    } else {
      dp[i][0] += dp[i + 1][0] * 2;
      dp[i][1] += dp[i + 1][0] + dp[i + 1][1] * 3;
    } 
    dp[i][0] %= MOD;
    dp[i][1] %= MOD;
  }
  return dp[0][1];
}
int main(){
  long long N, K;
  cin >> N >> K;
  cout << (f(N + K + 1) - f(K) + MOD) % MOD;
}
0