标签:code pen ble ace get bsp 没有 数字 ams
1 100 28 5437
418 900585
#include<iostream> using namespace std; int a,n,head1,head2,tail,que[1000001]; void Blah() { while(1) { int x=que[head1]*2+1,y=que[head2]*3+1; if(x>y)que[++tail]=y,head2++;//把较小的存到队列中,较大的再参与下一轮循环 else if(x<y)que[++tail]=x,head1++;//同理 else if(x==y) { que[++tail]=x; head1++; head2++; } if(tail>=n){ cout<<que[n]<<endl; return; } } } int main() { while(cin>>a>>n) { head1=1,head2=1,tail=1; que[1]=a; Blah(); } return 0; }
标签:code pen ble ace get bsp 没有 数字 ams
原文地址:http://www.cnblogs.com/thmyl/p/6194719.html