#include #include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int a, b, c, d, e; cin >> a >> b >> c >> d >> e; int x = b - c; if (x <= 0) { cout << 0 << endl; return 0; } int cur = d; int ans = cur * a; for (int i = 1; i < x; i++) { if (cur % 10 != 0) { ans += cur * a; } else if (e <= cur) { cur -= e; ans += cur * a; } else { ans += cur * a; } } cout << ans << endl; return 0; }