結果

問題 No.2881 Mod 2^N
ユーザー Fu_L
提出日時 2025-02-10 00:15:20
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 961 bytes
コンパイル時間 3,097 ms
コンパイル使用メモリ 278,896 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2025-02-10 00:15:26
合計ジャッジ時間 4,466 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<long long, long long>;
#define rep(i, a, b) for(long long i = (a); i < (b); ++i)
#define rrep(i, a, b) for(long long i = (a); i >= (b); --i)
constexpr long long inf = 4e18;
struct SetupIO {
    SetupIO() {
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout << fixed << setprecision(30);
    }
} setup_io;
int main(void) {
    ll n, x, y;
    cin >> n >> x >> y;
    if(y % 2 == 0) {
        if(x == y) {
            cout << 0 << '\n';
        } else {
            cout << -1 << '\n';
        }
        return 0;
    }
    vector<ll> a;
    while(true) {
        y--;
        if(y == 0) break;
        a.push_back(0);
        while(y % 2 == 0) {
            y /= 2;
            a.back()++;
        }
    }
    a.push_back(n);
    ranges::reverse(a);
    cout << ssize(a) << '\n';
    rep(i, 0, ssize(a)) {
        cout << a[i] << " \n"[i + 1 == ssize(a)];
    }
}
0