#include <iostream> #include <vector> #include <cmath> std::vector<int> getInput(){ int info; std::vector<int> coins; std::cin >> info; uint64_t val; for (int i=0; i<info; i++){ std::cin >> val; coins.push_back(val); } return coins; } uint64_t getValue(const int& num){ return (1<<num); } short getPower(const uint64_t& num){ return std::log2(num); } int main(){ std::vector<int> coins = getInput(); uint64_t sum = 0; for (const int& coin : coins){ sum += getValue(coin); } short sumPow = getPower(sum); std::cout << sumPow << "\n"; return sumPow; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | #include <iostream> #include <vector> #include <cmath> std::vector<int> getInput(){ int info; std::vector<int> coins; std::cin >> info; uint64_t val; for (int i=0; i<info; i++){ std::cin >> val; coins.push_back(val); } return coins; } uint64_t getValue(const int& num){ return (1<<num); } short getPower(const uint64_t& num){ return std::log2(num); } int main(){ std::vector<int> coins = getInput(); uint64_t sum = 0; for (const int& coin : coins){ sum += getValue(coin); } short sumPow = getPower(sum); std::cout << sumPow << "\n"; return sumPow; } |