#include #include extern int getchar_unlocked(void); extern int putchar_unlocked(int); #define gc(d) (d)=getchar_unlocked() #define pc(d) putchar_unlocked(d) static char *GETWORD(char* r) {char c;char *cp;cp=&r[0];gc(c);while(c!=EOF){if((c==' ')||(c=='\n'))break;*cp++=c;gc(c);}*cp='\0';return &r[0];} #define SWAP(type,a,b) do{type _c;_c=a;a=b;b=_c;}while(0) #define MAX(a,b) ((a)>(b)?(a):(b)) #define MIN(a,b) ((a)<(b)?(a):(b)) #define REP(a,b) for(int a=0;a<(int)(b);++a) #define REP1(a,b) for(int a=1;a<=(int)(b);++a) #define ull unsigned long long void out(int n) { int i; char b[70]; if (!n) pc('0'); else { if (n < 0) pc('-'), n = -n; i = 0; while (n) b[i++] = n % 10 + '0', n /= 10; while (i--) pc(b[i]); } pc('\n'); } void outl(ull n) { int i; char b[70]; if (!n) pc('0'); else { if (n < 0) pc('-'), n = -n; i = 0; while (n) b[i++] = n % 10 + '0', n /= 10; while (i--) pc(b[i]); } pc('\n'); } ull a2l(char *r) { ull res = 0; ull sign= 1; int i=0; while ((r[i]==' ')||(r[i]=='\t')||(r[i]=='\n')||(r[i]=='\v')||(r[i]=='\r')||(r[i]=='\f')) i++; if (r[i] == '-') sign = -1; if (r[i] == '+' || r[i] == '-') i++; while ((r[i]>='0')&&(r[i]<='9')){ ull dmy = res; res <<= 3; dmy <<= 1; res = res + dmy; res += (ull)(r[i] - '0'); i++; } return res * sign; } // ********************* int in() // 整数の入力(負数に対応) { int c,n = 0; gc(c); do { n = 10 * n + (c & 0xf); gc(c); } while (c >= '0'); return n; } void ins(char *s) // 文字列の入力 スペース以下の文字で入力終了 { do { gc(*s); } while (*s++ > ' '); *(s - 1) = 0; } // ********************* int main( void ) { int a,b,c,d,e,x; int need; int money = 0; scanf("%d%d%d%d%d",&a,&b,&c,&d,&e); need = MAX( b - c, 0 ) * a; //fprintf(stderr,"need=%d\n", need); if( need > 0 ) money = x = d; for(int i=2; i <= need ; i++ ) { //fprintf(stderr,"i%d ", i); if( i % 10 ) { money += x; } else { if( e <= x ) { x = x - e; } money += x; } //fprintf(stderr,"%d\n", money); } //fprintf(stderr,"money=%d\n", money); out(money); }