Skip to main content

Practices

2182 A. New Year String

py
import sys

num_of_input = int(sys.stdin.readline())
solves = num_of_input

for _ in range(num_of_input):
solutions = [int(i) for i in sys.stdin.readline().split()]
if sum(solutions) < 2:
solves -= 1
sys.stdout.write(str(solves))
CPP
#include <iostream>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <bits/stdc++.h>
#include <ranges>
#include <algorithm>

using namespace std;

int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);

int n;
if (!(cin >> n)) return 0;

int total_solved = 0;

for (int i = 0; i < n; ++i) {
int p, v, t;
cin >> p >> v >> t; // Read the 3 friends' opinions

// If at least two friends are sure (sum is 2 or 3)
if (p + v + t >= 2) {
total_solved++;
}
}

cout << total_solved << endl;

return 0; // Always return 0
}

2182 B. New Year Cake

import sys

num_of_input = int(sys.stdin.readline())

def get_max_layer(a, b):
curr = 1
layers = 0

while True:
if layers % 2 == 0:
if a >= curr:
a -= curr
else:
break
else:
if b >= curr:
b -= curr
else:
break
layers += 1
curr *= 2

return layers


for _ in range(num_of_input):
a, b = map(int, sys.stdin.readline().split())

ans1 = get_max_layer(a, b)
ans2 = get_max_layer(b, a)

sys.stdout.write(str(max(ans1, ans2)) + '\n')