/** * author: shu8Cream * created: 31.03.2021 20:51:18 **/ #include using namespace std; #define rep(i,n) for (int i=0; i<(n); i++) #define all(x) (x).begin(), (x).end() using ll = long long; using P = pair; using vi = vector; using vvi = vector; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int a,b,c,d,e; cin >> a >> b >> c >> d >> e; int ans = 0; if(b-c<=0){ cout << 0 << endl; return 0; } int tmp = d; for(int i=1; i<=a; i++){ if(i==1) ans+=(b-c)*tmp; else{ if(i%10!=0) ans+=(b-c)*tmp; if(i%10==0 && e<=tmp){ tmp-=e; ans+=(b-c)*tmp; } if(i%10==0 && e>tmp) ans=(b-c)*tmp; } } cout << ans << endl; }