1 solutions

  • 0
    @ 2025-10-27 16:31:42
    #include<bits/stdc++.h>
    using namespace std;
    typedef long long LL;
    const int N=1e6+10;
    LL q[N];
    int main()
    {
    	LL a,n;
    	while(cin>>a>>n)
    	{
    		q[1]=a;
    		int two=1,three=1;
    		for(int i=2;i<=n;i++)
    		{
    			LL t=min(q[two]*2+1,q[three]*3+1);
    			if(t==2*q[two]+1) two++;
    			if(t==3*q[three]+1) three++;
    			q[i]=t;
    		}
    		cout<<q[n]<<endl;
    	}
    	return 0;
    }
    
    • 1

    Information

    ID
    962
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    5
    Tags
    (None)
    # Submissions
    57
    Accepted
    22
    Uploaded By