結果

問題 No.2241 Reach 1
ユーザー Jeroen Op de Beek
提出日時 2023-03-10 22:02:15
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 20 ms / 2,000 ms
コード長 1,460 bytes
コンパイル時間 1,761 ms
コンパイル使用メモリ 192,432 KB
最終ジャッジ日時 2025-02-11 08:19:42
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 35
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
#define all(x) begin(x),end(x)
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }
template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { string sep; for (const T &x : v) os << sep << x, sep = " "; return os; }
#define debug(a) cerr << "(" << #a << ": " << a << ")\n";
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pi;
const int mxN = 1e5+1, oo = 1e9;
int main() {
    int N; cin >> N;
    // remove trailing zeroes
    // do times a number + 1
    // need to make number of bits less.
    // it's possible in log(n) moves, have only few choices?
    // always do towards that.
    // multiplication by 3 could cancel a lot...
    // 6 do towards that 3 and then 2 left.
    // multiplication is so chaotic!
    // want to get (2^k-1)/something  = my number
    // (2^k - 1)(2^k+1)
    // can do +1 anyway, gives a new bound.
    // want to get 2^b - 2^a -1. A lot of freedom...
    // how to get there? 100000000
    // how to get there?
    if(1<<__lg(N)==N) {
        cout << "1\n";
    } else {
        int ans = 3; // shift then multiply to get 2-power - 1 + 1
        if(N%2==1) ans--;
        cout << ans << '\n';
    }

}
0