#include using namespace std; using u64 = uint_least64_t; using s64 = int_least64_t; using ll = uint_least64_t; int main(){ int a,b,c,d,e; cin >> a >> b >> c >> d >> e; int friend_num = b - c; int candy_num = a * friend_num; if (candy_num == 0){ cout << '0' << endl; return 0; } if (candy_num == 1){ cout << d << endl; return 0; } int x = d; int price = x; for (int i = 2; i <= candy_num; ++i){ if (i % 10 != 0){ price += x; } else{ if (i % 10 == 0){ if (e <= x){ x -= e; price += x; } else{ price += x; } } } } cout << price << endl; return 0; }