|
|
back to boardDiscussion of Problem 1113. JeepWhere is mistake? #include <iostream> #include <stdlib.h> using namespace std; int main() { int m, n, f; double out; div_t o; double way[32005] = {0}; long long int oil[32005] = {0}; cin >> n >> m; way[1] = m; oil[1] = m;
for(f = 1; way[f - 1] + m / (2 * f - 1) < n; f++) { way[f] = way[f - 1] + m / (2 * f - 1); oil[f] = f * m; } out = (n - way[f - 1]) * (2 * f - 1) + oil[f - 1]; o = div(out, 1); if(abs(out - o.quot) < 1e-8) cout << o.quot; else cout << o.quot + 1;
} |
|
|