Skip to content

Commit e802aa0

Browse files
committed
Solve problems 014A and 014B from AtCoder
1 parent 00d86cd commit e802aa0

File tree

3 files changed

+61
-0
lines changed

3 files changed

+61
-0
lines changed

AtCoder/014A - Cookie Exchanges.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#include <iostream>
2+
3+
using namespace std;
4+
5+
int main() {
6+
int a, b, c;
7+
cin >> a >> b >> c;
8+
9+
int res = 0, lol = 1;
10+
while(a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {
11+
if(lol == 1e6 + 1) {
12+
cout << -1 << endl;
13+
return 0;
14+
}
15+
16+
int tmpa = a / 2;
17+
int tmpb = b / 2;
18+
int tmpc = c / 2;
19+
20+
a = tmpb + tmpc;
21+
b = tmpa + tmpc;
22+
c = tmpa + tmpb;
23+
24+
res++;
25+
lol++;
26+
}
27+
28+
cout << res << endl;
29+
30+
return 0;
31+
}

AtCoder/014B - Unplanned Queries.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#include <iostream>
2+
3+
using namespace std;
4+
5+
int const N = 1e5 + 1;
6+
int freq[N];
7+
8+
int main() {
9+
int n, m;
10+
cin >> n >> m;
11+
12+
int a, b;
13+
for(int i = 0; i < m; ++i) {
14+
cin >> a >> b;
15+
++freq[--a];
16+
++freq[--b];
17+
}
18+
19+
for(int i = 0; i < n; ++i)
20+
if(freq[i] % 2 != 0) {
21+
cout << "NO" << endl;
22+
return 0;
23+
}
24+
25+
cout << "YES" << endl;
26+
27+
return 0;
28+
}

AtCoder/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,5 @@
1212
- [060B - Choose Integers](http://abc060.contest.atcoder.jp/tasks/abc060_b)
1313
- [060C - Sentou](http://abc060.contest.atcoder.jp/tasks/arc073_a)
1414
- [060D - Simple Knapsack](http://abc060.contest.atcoder.jp/tasks/arc073_b)
15+
- [014A - Cookie Exchanges](http://agc014.contest.atcoder.jp/tasks/agc014_a)
16+
- [014B - Unplanned Queries](http://agc014.contest.atcoder.jp/tasks/agc014_b)

0 commit comments

Comments
 (0)