結果
問題 | No.1531 く2 |
ユーザー |
👑 ![]() |
提出日時 | 2021-06-04 21:24:03 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 853 bytes |
コンパイル時間 | 698 ms |
コンパイル使用メモリ | 73,400 KB |
最終ジャッジ日時 | 2025-01-21 23:53:21 |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 WA * 1 |
other | AC * 11 WA * 33 |
ソースコード
#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;