#include #ifndef LOCAL_ #define fprintf if( false ) fprintf #endif // LOCAL_ #define dumpi(x1) fprintf(stderr, "#%s.%d (%s) = (%d)\n", __func__, __LINE__, #x1, x1); #define dumpii(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%d, %d)\n", __func__, __LINE__, #x1, #x2, x1, x2); #define dumpiii(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%d, %d, %d)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3); #define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1); #define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1); int h, a, d; double es[11234]; double e(int x) { if( x <= 0 ) return 0.0; return es[x]; } int main() { scanf("%d %d %d", &h, &a, &d); for(int i = 1; i <= h; ++i) { double base = 0.0; double min = 10000000; for(int j = 0; j < 100; ++j) { if( j > 0 ) base += pow(1.0/3.0, j) * (j + e(i-d)); double t = 2.0 * base + pow(1.0/3.0, j) * ((j + 1) + e(i-a)); min = std::min(min, t); // dumpd(t); } dumpd(min); double t1 = 1.0 + e(i-a); double t2 = 2.0 * (pow(1.0/3.0, 1) * (1 + e(i-d))) + (1.0/3.0) * (2 + e(i-a)); double t3 = 2.0/3.0 * (1 + e(i-d)) + (1.0/3.0)*(2.0/3.0) * (2 + e(i-d)) + (1.0/3.0)*(1.0/3.0)*(3 + e(i-a)); double t4 = 2.0 * (pow(1.0/3.0, 1) * (1 + e(i-d)) + pow(1.0/3.0, 2) * (2 + e(i-d)) + pow(1.0/3.0, 3) * (3 + e(i-d))) + pow(1.0/3.0, 3) * (4 + e(i-a)); dumpd(t1); dumpd(t2); dumpd(t3); dumpd(t4); es[i] = std::min(std::min(std::min(t1, t2), t3), t4); } return 0; }