Skip to content

Commit d5b98d8

Browse files
authored
Merge pull request #404 from xirc/atcoder/abc027
AtCoder/ABC027
2 parents 129af12 + 926de3f commit d5b98d8

File tree

3 files changed

+96
-0
lines changed

3 files changed

+96
-0
lines changed

atcoder/abc027/A/main.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
using ll = int64_t;
5+
using ff = long double;
6+
7+
int main() {
8+
ios_base::sync_with_stdio(false);
9+
cin.tie(0); cout.tie(0);
10+
11+
vector<int> ls(3);
12+
cin >> ls[0] >> ls[1] >> ls[2];
13+
int ans = 0;
14+
if (ls[0] == ls[1]) ans = ls[2];
15+
if (ls[1] == ls[2]) ans = ls[0];
16+
if (ls[2] == ls[0]) ans = ls[1];
17+
cout << ans << endl;
18+
19+
return 0;
20+
}

atcoder/abc027/B/main.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
using ll = int64_t;
5+
using ff = long double;
6+
7+
int N;
8+
vector<int> A;
9+
10+
int solve() {
11+
int M = accumulate(A.begin(), A.end(), 0, plus<int>());
12+
if (M % N != 0) return -1;
13+
M /= N;
14+
15+
int ans = 0;
16+
int acc = 0;
17+
for (auto ai : A) {
18+
acc += ai - M;
19+
if (acc != 0) ans += 1;
20+
}
21+
return ans;
22+
}
23+
24+
int main() {
25+
ios_base::sync_with_stdio(false);
26+
cin.tie(0); cout.tie(0);
27+
28+
cin >> N;
29+
A.assign(N, 0);
30+
for (auto &ai : A) cin >> ai;
31+
cout << solve() << endl;
32+
33+
return 0;
34+
}

atcoder/abc027/C/main.cpp

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
using ll = int64_t;
5+
using ff = long double;
6+
7+
int bits(ll N) {
8+
int bc = 0;
9+
while (N > 0) {
10+
N >>= 1;
11+
++bc;
12+
}
13+
return bc;
14+
}
15+
16+
bool solve(ll N) {
17+
int const M = bits(N);
18+
ll v = 1;
19+
int i = 0;
20+
for (; v <= N; ++i) {
21+
v <<= 1;
22+
if (i % 2 == 0 && M % 2 == 1) {
23+
v += 1;
24+
}
25+
if (i % 2 == 1 && M % 2 == 0) {
26+
v += 1;
27+
}
28+
}
29+
return i % 2 == 0;
30+
}
31+
32+
int main() {
33+
ios_base::sync_with_stdio(false);
34+
cin.tie(0); cout.tie(0);
35+
36+
ll N;
37+
cin >> N;
38+
auto ans = solve(N) ? "Takahashi" : "Aoki";
39+
cout << ans << endl;
40+
41+
return 0;
42+
}

0 commit comments

Comments
 (0)