Source Code
//
//  main.cpp
//  to_be_better
//
//  Created by Malek Alsadi on 26/05/2021.#include <string>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;
void magic(){
    int n,m,k;cin>>n>>m>>k;
    int sum=0;int mx=max(m,k),mn=min(m,k);int y=0;int con=mx;
    while(y<n){
        sum+=mn;
        y++;
        if(sum>=mx){
            mx+=con;
            y++;
        }
    }
    cout<<sum;
}
int main() {
  int w=1;
  //cin>>w;
    while(w--){
        magic();
        cout<<endl;
    }

  return 0;
}
Copy
Hurry up Malek
GNU G++17
272 ms
440 KB
Wrong Answer