3 solutions

  • 0
    @ 2022-3-31 19:18:21
    #include<bits/stdc++.h>
    using namespace std;
    int x,n;
    int main(){
    	std::ios::sync_with_stdio(false);
    	while(cin>>x>>n){
    		queue <int> num,num2,num3;
    		num.push(x);
    		int i=1;
    		for(;i<n;i++){//
    			num2.push(num.back()*2+1);
    			num3.push(num.back()*3+1);
    			if(num2.front()<num3.front()){
    				num.push(num2.front());
    				num2.pop();
    			}else if(num2.front()>num3.front()){
    				num.push(num3.front());
    				num3.pop();
    			}else{
    				num.push(num3.front());
    				num3.pop();
    				num2.pop();
    			}
    		}
    		cout<<num.back()<<endl;
    	}
    	return 0;
    }
    

    Information

    ID
    297
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    5
    Tags
    # Submissions
    23
    Accepted
    12
    Uploaded By