其他分享
首页 > 其他分享> > 1333

1333

作者:互联网

#include <iostream>
#include <algorithm>
using namespace std;
int const N = 1000100;
long long q[N];
int a,n;
void work(int a,int n){
	int rear = 2;
	q[1] = a;
	int two= 1,three = 1;
	while (rear <= n) {
		long long t1 = q[two] * 2 + 1,t2 = q[three] * 3 + 1;
		int t = min(t1,t2);
		if (t1 < t2) two++;
		else three++;
		if (t == q[rear-1]) continue;
		q[rear++] = t;
	}
	cout <<q[n] << endl;
}
int main () {
	while (cin >> a >> n) work(a,n);
	return 0;
}


标签:std,int,work,long,1333,include,rear
来源: https://blog.csdn.net/weixin_45476788/article/details/97942936