소감 ¶
2006-01-08 Accepted 0.012 Minimum |
코드 ¶
~cpp // 846 - Steps #include <iostream> using namespace std; #include <cmath> inline void process(int n) { int i = floor(sqrt(n)); for (; i * (i + 1) <= n; i++) ; if (n == i * (i - 1)) cout << 2 * (i - 1) << endl; else if (n <= i * i) cout << 2 * i - 1 << endl; else cout << 2 * i << endl; } int main() { int nCase, x, y; cin >> nCase; for (int i = 0; i < nCase; i++) { cin >> x >> y; process(y - x); } return 0; }