IT Study/Algorithm
[백준 알고리즘]1011번 Fly me to the Alpha Centauri
도뿌리
2018. 8. 21. 10:34
규칙에 대한 내용 써야함(좀있다 업데이트)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | #include <stdio.h> int main(void) { int test_case; scanf("%d",&test_case); for(int i = 0 ; i <test_case ; i++){ int x,y; scanf("%d %d",&x,&y); int distance = y-x; int i = 2; while(i*i-(i-1) > distance || i*i+i < distance){ i++; } if(i*i < distance){ printf("%d\n",2*i); }else{ printf("%d\n",2*i-1); } } return 0; } | cs |