打印+动态规划
3302. 打印
ECNU-3302
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<vector>
#include<unordered_map>
using namespace std;
typedef long long LL;
const int maxn=10000007;
LL dp[maxn];
int main(){
int n;
LL x,y;
cin>>n>>x>>y;
memset(dp,0,sizeof(dp));
for(int i=1;i<=n;i++){
if(i%2==0){//偶数
dp[i]=min(dp[i-1]+x,dp[i/2]+y);
}else{//奇数
dp[i]=min(dp[i-1]+x,dp[(i+1)/2]+y+x);
}
}
if(n==1)
cout<<x<<endl;
else{
cout<<dp[n]<<endl;
}
return 0;
}
Either Excellent or Rusty