[백준] 1011번 : Fly me to the Alpha Centauri - C

강재원·2022년 10월 25일
0

[코딩테스트] C/C++

목록 보기
148/200



https://www.acmicpc.net/problem/1011

#include<stdio.h>
#include<math.h>

int main() {
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        int x,y;
        scanf("%d %d",&x,&y);
        int k=1;
        int count=0;
        
        while(x<y){
            x+=k;
            count++;
            if(x>=y) break;
            y-=k;
            count++;
            k++;
        }
        printf("%d\n",count);
    }
}
profile
개념정리 & 문법 정리 & 알고리즘 공부

0개의 댓글