Skip to content

Commit ecb572d

Browse files
authored
Merge pull request #321 from xirc/atcoder/abc083
AtCoder/ABC083
2 parents 5504e8c + 1610861 commit ecb572d

File tree

4 files changed

+85
-15
lines changed

4 files changed

+85
-15
lines changed

atcoder/abc083/A/main.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
using ll = long long;
5+
6+
int main() {
7+
ios_base::sync_with_stdio(false);
8+
cin.tie(0); cout.tie(0);
9+
10+
int A, B, C, D;
11+
cin >> A >> B >> C >> D;
12+
int L = A + B, R = C + D;
13+
if (L > R) {
14+
cout << "Left" << endl;
15+
} else if (L < R) {
16+
cout << "Right" << endl;
17+
} else {
18+
cout << "Balanced" << endl;
19+
}
20+
21+
return 0;
22+
}

atcoder/abc083/B/main.cpp

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,36 @@
11
#include <bits/stdc++.h>
22

33
using namespace std;
4+
using ll = long long;
45

5-
int digsum(int V) {
6-
int sum = 0;
7-
while (V > 0)
8-
{
9-
sum += V % 10;
10-
V /= 10;
6+
int N, A, B;
7+
8+
int digsum(int m) {
9+
int s = 0;
10+
while (m > 0) {
11+
s += m % 10;
12+
m /= 10;
1113
}
12-
return sum;
14+
return s;
1315
}
1416

15-
int solve(int N, int A, int B) {
16-
int ans = 0;
17+
int solve() {
18+
int sum = 0;
1719
for (int i = 1; i <= N; ++i) {
18-
int sum = digsum(i);
19-
if (sum >= A && sum <= B) {
20-
ans += i;
20+
int ds = digsum(i);
21+
if (ds >= A && ds <= B) {
22+
sum += i;
2123
}
2224
}
23-
return ans;
25+
return sum;
2426
}
2527

2628
int main() {
2729
ios_base::sync_with_stdio(false);
2830
cin.tie(0); cout.tie(0);
2931

30-
int N, A, B;
3132
cin >> N >> A >> B;
32-
cout << solve(N, A, B) << endl;
33+
cout << solve() << endl;
3334

3435
return 0;
3536
}

atcoder/abc083/C/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 = long long;
5+
6+
int main() {
7+
ios_base::sync_with_stdio(false);
8+
cin.tie(0); cout.tie(0);
9+
10+
ll X, Y;
11+
cin >> X >> Y;
12+
int len = 1;
13+
while (X * 2 <= Y) {
14+
++len;
15+
X *= 2;
16+
}
17+
cout << len << endl;
18+
19+
return 0;
20+
}

atcoder/abc083/D/main.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
using ll = long long;
5+
6+
int solve(string& S) {
7+
const int N = S.size();
8+
int ans = N;
9+
for (int i = 0; i + 1 < N; ++i) {
10+
if (S[i] != S[i+1]) {
11+
int m = max(i+1,N-(i+1));
12+
ans = min(ans, m);
13+
}
14+
}
15+
return ans;
16+
}
17+
18+
int main() {
19+
ios_base::sync_with_stdio(false);
20+
cin.tie(0); cout.tie(0);
21+
22+
string S;
23+
cin >> S;
24+
cout << solve(S) << endl;
25+
26+
return 0;
27+
}

0 commit comments

Comments
 (0)