結果

問題 No.642 Two Operations No.1
ユーザー tecchaxntecchaxn
提出日時 2018-02-02 21:41:29
言語 C++11
(gcc 11.4.0)
結果
MLE  
実行時間 -
コード長 742 bytes
コンパイル時間 1,759 ms
コンパイル使用メモリ 147,968 KB
実行使用メモリ 814,472 KB
最終ジャッジ日時 2023-08-30 02:05:09
合計ジャッジ時間 6,131 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 770 ms
298,820 KB
testcase_05 AC 951 ms
374,764 KB
testcase_06 MLE -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long

using namespace std;
typedef pair<int,int> P;

//-----------------------------------------------------------------------

const int INF=1e18;

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n; cin>>n;

    queue<int> que;
    que.push(n);
    
    int ans=0;
    while(!que.empty()){
        int sz=que.size();
        REP(i,sz){
            int x=que.front(); que.pop();
            if(x==1){
                cout<<ans<<endl;
                return 0;
            }else{
                que.push(x+1);
                if(x%2==0) que.push(x/2);
            }
        }
        ans++;
    }
}
0