Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- #define ll long long int
- ll CellMitosis(int n,int x,int y,int z){
- ll *dp = new ll[n+1];
- dp[0]=0;
- dp[1]=0;
- for(int i=2;i<=n;i++){
- if(i&1){
- dp[i] = min((dp[i-1]+y),dp[(i+1)/2]+x+z);
- }
- else{
- dp[i] = min((dp[i/2]+x),(dp[i-1]+y));
- }
- }
- return dp[n];
- }
- int main() {
- #ifndef ONLINE_JUDGE
- // for getting input from input.txt
- freopen("input.txt", "r", stdin);
- // for writing output to output.txt
- freopen("output.txt", "w", stdout);
- #endif
- ll n; cin >> n;
- ll x,y,z;
- cin >> x >> y >> z;
- cout << CellMitosis(n,x,y,z) << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement