Skip to content

Commit

Permalink
1011 Fly me to the Alpha Centauri / 수학
Browse files Browse the repository at this point in the history
  • Loading branch information
cjy8922 authored Mar 21, 2021
1 parent 73dd50e commit c205683
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions 2021_03/BJ_1011.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// https://www.acmicpc.net/problem/1011

#include <iostream>
using namespace std;

int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);

int T;
cin >> T;

for (int test_case = 1; test_case <= T; test_case++) {
int start, end, diff;
cin >> start >> end;
diff = end - start;

int count = 0, jump = 1;
while (diff > 0) {
if (diff <= jump) {
diff -= jump;
count++;
}

else {
diff -= jump * 2;
count += 2;
}

jump++;
}
cout << count << endl;
}

return 0;
}

0 comments on commit c205683

Please sign in to comment.