被这道题吓到了,看起来很复杂
#include <iostream> using namespace std; int main() { int n,k; while(cin >> n >> k) { if(n <= k) cout << 2 << endl; else if((2*n)%k>0) cout << (2*n/k) +1 << endl; else if((2*n)%k == 0) cout << n*2/k << endl; } return 0; }
原文:http://www.cnblogs.com/ekinzhang/p/4404051.html