File tree 4 files changed +85
-15
lines changed
4 files changed +85
-15
lines changed Original file line number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change 1
1
#include < bits/stdc++.h>
2
2
3
3
using namespace std ;
4
+ using ll = long long ;
4
5
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 ;
11
13
}
12
- return sum ;
14
+ return s ;
13
15
}
14
16
15
- int solve (int N, int A, int B ) {
16
- int ans = 0 ;
17
+ int solve () {
18
+ int sum = 0 ;
17
19
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;
21
23
}
22
24
}
23
- return ans ;
25
+ return sum ;
24
26
}
25
27
26
28
int main () {
27
29
ios_base::sync_with_stdio (false );
28
30
cin.tie (0 ); cout.tie (0 );
29
31
30
- int N, A, B;
31
32
cin >> N >> A >> B;
32
- cout << solve (N, A, B ) << endl;
33
+ cout << solve () << endl;
33
34
34
35
return 0 ;
35
36
}
Original file line number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments