File tree 14 files changed +210
-0
lines changed
14 files changed +210
-0
lines changed Original file line number Diff line number Diff line change
1
+ #include < bits/stdc++.h>
2
+
3
+ using namespace std ;
4
+
5
+ int main () {
6
+ int tc;
7
+ cin >> tc;
8
+
9
+ while (tc--) {
10
+ int n;
11
+
12
+ string arr;
13
+ cin >> arr;
14
+
15
+ n = arr.length ();
16
+
17
+ int x = 0 , y = 0 , ans = 0 ;
18
+ for (int i = 0 ; i < n; i++) {
19
+ if (arr[i] == ' x' )
20
+ x++;
21
+ if (arr[i] == ' y' )
22
+ y++;
23
+ }
24
+ while (x && y) {
25
+ ans++;
26
+ x--;
27
+ y--;
28
+ }
29
+
30
+ cout << ans << endl;
31
+ }
32
+
33
+ return 0 ;
34
+ }
Original file line number Diff line number Diff line change
1
+ #include < bits/stdc++.h>
2
+
3
+ using namespace std ;
4
+
5
+ int solve (int a, int b) {
6
+ if (a == 0 || b == 0 )
7
+ return 0 ;
8
+ int sh = 0 , sw = 0 , ans = 0 ;
9
+
10
+ if (a > b) {
11
+ while (a > 1 ) {
12
+ a -= 2 ;
13
+ b -= 1 ;
14
+ sh++;
15
+ }
16
+ } else {
17
+ while (b > 1 ) {
18
+ b -= 2 ;
19
+ a -= 1 ;
20
+ sw++;
21
+ }
22
+ }
23
+
24
+ return max (sh, sw);
25
+ }
26
+ int main () {
27
+ int tc;
28
+ cin >> tc;
29
+
30
+ while (tc--) {
31
+ int a, b;
32
+ cin >> a >> b;
33
+
34
+ int ans = solve (a, b);
35
+
36
+ cout << ans << endl;
37
+ }
38
+ return 0 ;
39
+ }
Original file line number Diff line number Diff line change
1
+ #include < bits/stdc++.h>
2
+ using namespace std ;
3
+
4
+ int main () {
5
+
6
+ int tc;
7
+
8
+ cin >> tc;
9
+
10
+ while (tc--) {
11
+ int n;
12
+ cin >> n >> k;
13
+ }
14
+ }
Original file line number Diff line number Diff line change
1
+ #include < bits/stdc++.h>
2
+ using namespace std ;
3
+ int main () {
4
+ int a, b;
5
+ cin >> a >> b;
6
+ cout << ((a * b) / 2 ) << endl;
7
+ return 0 ;
8
+ }
Original file line number Diff line number Diff line change
1
+ #include < bits/stdc++.h>
2
+
3
+ using namespace std ;
4
+
5
+ int main () {
6
+ int n, k;
7
+
8
+ cin >> n >> k;
9
+
10
+ int arr[51 ];
11
+
12
+ for (int i = 0 ; i < n; i++)
13
+ cin >> arr[i];
14
+
15
+ int ans = 0 ;
16
+
17
+ for (int i = 0 ; i < n; i++) {
18
+ if (arr[i] && arr[k - 1 ] <= arr[i])
19
+ ans++;
20
+ }
21
+
22
+ cout << ans << endl;
23
+
24
+ return 0 ;
25
+ }
Original file line number Diff line number Diff line change
1
+ #include < bits/stdc++.h>
2
+
3
+ using namespace std ;
4
+
5
+ int main () {
6
+ char s;
7
+ while (cin >> s)
8
+ if (!strchr (" AEIOUYaeiouy" , s))
9
+ cout << ' .' << (char )tolower (s);
10
+
11
+ return 0 ;
12
+ }
Original file line number Diff line number Diff line change
1
+ #include < bits/stdc++.h>
2
+
3
+ using namespace std ;
4
+
5
+ int main () {
6
+ int tc;
7
+
8
+ cin >> tc;
9
+ int a, b, c, ans = 0 ;
10
+ for (int i = 0 ; i < tc; i++) {
11
+ cin >> a >> b >> c;
12
+
13
+ if ((a && b) || (a && c) || (b && c))
14
+ ans++;
15
+ }
16
+
17
+ cout << ans << endl;
18
+ return 0 ;
19
+ }
Original file line number Diff line number Diff line change
1
+ #include < bits/stdc++.h>
2
+
3
+ using namespace std ;
4
+
5
+ int main () {
6
+
7
+ int a, b, c;
8
+
9
+ cin >> a >> b >> c;
10
+
11
+ cout << 1LL * ((a + c - 1 ) / c) * ((b + c - 1 ) / c) << endl;
12
+
13
+ return 0 ;
14
+ }
Original file line number Diff line number Diff line change
1
+ #include < bits/stdc++.h>
2
+
3
+ using namespace std ;
4
+
5
+ int main () {
6
+
7
+ int n;
8
+
9
+ cin >> n;
10
+
11
+ while (n--) {
12
+
13
+ string s;
14
+
15
+ cin >> s;
16
+
17
+ if (s.length () <= 10 )
18
+ cout << s;
19
+
20
+ else
21
+
22
+ cout << s.front () << s.length () - 2 << s.back ();
23
+
24
+ cout << endl;
25
+ }
26
+
27
+ return 0 ;
28
+ }
Original file line number Diff line number Diff line change
1
+ #include < bits / stdc++.h>
2
+
3
+ using namespace std ;
4
+
5
+ int main () {
6
+
7
+ int n;
8
+ cin >> n;
9
+
10
+ if (n % 2 || n == 2 )
11
+ cout << " NO" << endl;
12
+
13
+ else
14
+ cout << " YES" << endl;
15
+
16
+ return 0 ;
17
+ }
You can’t perform that action at this time.
0 commit comments