欢迎光临散文网 会员登陆 & 注册

Blah

2023-07-11 17:33 作者:SpiderMonkeyLing  | 我要投稿

#include <iostream>
#include <cstdio>
using namespace std;
const int N=10000001;
int q[N],x[N],y[N];
int hh,tt,xh,yh,xt,yt;
int main()
{
    int a,n;
    while(cin>>a>>n) {
        q[tt++]=a;
        for(int i=0;i<n;i++) {
            a=q[hh++];
            x[xt++]=2*a+1;
            y[yt++]=3*a+1;
            if(x[xh]<y[yh]) {
                q[tt++]=x[xh++];
            }
            else if(x[xh]>y[yh]) {
                q[tt++]=y[yh++];
            }
            else {
                q[tt++]=y[yh++];
                xh++;
            }
        }
        cout<<q[hh-1]<<endl;
        hh=0,tt=0,xh=0,yh=0,xt=0,yt=0;
    }
    return 0;
}

Blah的评论 (共 条)

分享到微博请遵守国家法律