Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
121023 | 方文轩 | Blah数集 | C++ | 通过 | 100 | 0 MS | 512 KB | 395 | 2024-01-21 14:52:21 |
#include<bits/stdc++.h> using namespace std; long long q[1000100]; int n,a; 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; }