반응형
#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;
int main(){
int T;
scanf("%d", &T);
for(int i = 0; i < T; ++i){
long long x, y;
cin >> x >> y;
long long move, max = 0;
while(max * max <= y - x)
max++;
max--;
move = 2 * max - 1;
long long rest_dist = y - x - max * max;
rest_dist = (long long)ceil((double)rest_dist / (double)max);
move += rest_dist;
printf("%lld\n", move);
}
return 0;
}
반응형
'알고리즘 > 백준(BOJ)' 카테고리의 다른 글
백준 2581 소수 (0) | 2021.02.28 |
---|---|
백준 1978 소수찾기 (0) | 2021.02.28 |
백준 1010 다리놓기 (0) | 2021.02.21 |
백준 1260 DFS와 BFS (0) | 2021.02.12 |
17143 낚시왕 (0) | 2021.02.08 |