Recent Posts
Notice
No Rules Rules
Steps (feat. 백준, 4395번) 본문
728x90
반응형
Steps
https://www.acmicpc.net/problem/4395
4395번: Steps
One steps through integer points of the straight line. The length of a step must be nonnegative and can be by one bigger than, equal to, or by one smaller than the length of the previous step. What is the minimum number of steps in order to get from x to y
www.acmicpc.net
반응형
// woohyeon.kim
// kim519620.tistory.com
#include <iostream>
#include <cmath>
using namespace std;
int main() {
ios::sync_with_stdio(false), cin.tie(NULL);
register int N, X, Y;
cin >> N;
for (register int n = 0; n < N; ++n) {
cin >> X >> Y;
if (X == Y)
cout << 0;
else {
register int t = sqrt(Y - X);
if (t * t == Y - X)
cout << 2 * t - 1;
else {
register int Z = (Y - X) - t * t;
if (Z <= t)
cout << 2 * t;
else
cout << 2 * t + 1;
}
}
cout << "\n";
}
return 0;
}
// *&)*@*
아래 "멍멍이 쓰다듬기" 와 동일한 유형의 문제입니다.
멍멍이 쓰다듬기 (feat. 백준, 1669번)
멍멍이 쓰다듬기 https://www.acmicpc.net/problem/1669 1669번: 멍멍이 쓰다듬기 동물원에서 막 탈출한 원숭이 한 마리가 세상구경을 하고 있다. 그러다 오늘도 어김없이 그의 영원한 라이벌 멍멍이를 만
kim519620.tistory.com
728x90
반응형
'생활 > 코테' 카테고리의 다른 글
신비로운 수 (feat. 백준, 17433번) (0) | 2022.09.06 |
---|---|
같은 나머지 (feat. 백준, 1684번) (0) | 2022.09.06 |
멍멍이 쓰다듬기 (feat. 백준, 1669번) (0) | 2022.09.06 |
보드 점프 (feat. 백준, 3372번) (2) | 2022.09.06 |
점프 (feat. 백준, 1890번) (0) | 2022.09.06 |