杭电 hdu ACM 1049 Climbing Worm

水题

 

#include <iostream> using namespace std; int cnt, n, u, d; void GreedySelector() { int sum = 0; cnt = 0; while(1) { sum += u; ++cnt; if( sum >= n ) break; sum -= d; ++cnt; } } int main() { while ( cin >> n >> u >> d && n && u && d ) { GreedySelector(); cout << cnt << endl; } return 0; }  

你可能感兴趣的:(杭电 hdu ACM 1049 Climbing Worm)