Код
#include <iostream>#include <vector>int main() { int n; std::vector<int> sequence; std::cin >> n; for(auto i = 0; i < n; ++i) { int number; std::cin >> number; sequence.push_back(number); } int as = 0, bs = 0, cs = 0; for (auto &el : sequence) { switch (el) { case 1: ++as; break; case 2: ++bs; break; case 3: ++cs; break; default: throw std::runtime_error("All elements shall be into [1;3] range."); } } int an_answer = std::min({bs + cs, as + cs, bs + cs}); std::cout << an_answer << std::endl; return 0;}
Відповідь:
from random import randint
lst=[]
while sum(lst)<250:
lst.append(randint(1,100))
print("Кульок:",len(lst))
print("Сума кульок:",sum(lst))
if len(lst)<10:
print("Петрик виграв.")
elif len(lst)>10:
print("Спробуй ще.")
Пояснення: