Skip to content

Commit

Permalink
3142. 영준이와 신비한 뿔의 숲
Browse files Browse the repository at this point in the history
  • Loading branch information
cjy8922 authored Mar 21, 2021
1 parent c205683 commit f3e6fbd
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions 2021_03/SWEA_3142.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#include <iostream>
#include <algorithm>
#include <vector>
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 horns, animals;
cin >> horns >> animals;

int animals1 = 0, animals2 = animals;
while (true) {
if (animals1 + animals2 * 2 == horns) {
cout << "#" << test_case << " " << animals1 << " " << animals2 << endl;
break;
}

else if (animals1 + animals2 * 2 > horns) {
animals2--;
animals1++;
}

else {
animals2++;
animals1--;
}
}
}
return 0;
}

0 comments on commit f3e6fbd

Please sign in to comment.