結果
| 問題 |
No.1952 xooooooooooor
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-05-26 00:00:08 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,096 bytes |
| コンパイル時間 | 4,026 ms |
| コンパイル使用メモリ | 252,532 KB |
| 最終ジャッジ日時 | 2025-01-29 15:19:04 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 37 WA * 2 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
//#define DISABLE_PRINT
#if defined(ENABLE_PRINT) && !defined(DISABLE_PRINT)
#define P(...) fprintf(stderr, __VA_ARGS__)
#define P2(fmt) fprintf(stderr, fmt)
#define LP fprintf(stderr, "L: %d\n", __LINE__)
#else
#define P(...) ((void)0)
#define P2(fmt) ((void)0)
#define LP ((void)0)
#endif
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define ALL(x) x.begin(),x.end()
using ll = long long;
using ull = unsigned long long;
using mint = atcoder::modint998244353;
int main(int, const char**)
{
ull N, M; cin >> N >> M;
if(N == 0) {
cout << 0 << endl;
return 0;
}
auto f = [&](ull x) {
vector<int> ds;
while(x != 0) {
ds.push_back(x % 2);
x /= 2;
}
return ds;
};
auto ds = f(N);
if(M <= ds.size()) {
assert(M <= 32);
ull ans = 0;
auto x = N;
rep(i, M) {
ans ^= x;
x <<= 1;
}
cout << ans << endl;
return 0;
}
auto len = (int)ds.size();
mint ans = 0;
mint base = 1;
int v = 0;
rep(i, len - 1) {
v ^= ds[i];
ans += base * v;
base *= 2;
P("%d", v);
}
P("\n");
auto mlen = M - len + 1;
v ^= ds.back();
if(v == 1) {
auto tb = mint(2).pow(mlen) - 1;
tb *= base;
ans += tb;
P("tb: %d\n", tb);
}
P("ans: %ld\n", ans.val());
vector<int> tops;
v = 0;
rep(i, len - 1) {
v ^= ds[len - 1 - i];
P("%d, \n", v);
tops.push_back(v);
}
P("\n");
base = mint(2).pow(mlen + len - 1);
P("base: %d\n", base.val());
rep(i, len - 1) {
auto tv = tops[len - 2 - i];
P("tv: %d\n", tv);
ans += base * tv;
base *= 2;
}
cout << ans.val() << endl;
vector<int> av;
auto x = ans.val();
while(x != 0) {
av.push_back(x % 2);
x /= 2;
}
for(auto a : av) {
P("%d", a);
}
P("\n");
return 0;
}