#include <iostream>
#include <vector>
using namespace std;
class K{
friend int main();
vector <long long> wynik;
public:
int potega(int a, int b);
int f(int x);
int wyszukaj_binarnie(int a, int b);
};
int K::potega(int a, int b){
if(b == 0){
return 1;
}
else{
return a = a * potega(a, --b);
}
}
int main(){
K Potega;
vector <int> pot;
//WEJSCIE
int n;
cin >> n;
for(int i = 0; i < n; i++){
int k;
cin >> k;
pot.push_back(k);
}
//OTRZYMANIE SUMY
long long suma = 0;
for(int i = 0; i < n; i++){
Potega.wynik.push_back(Potega.potega(2, pot[i]));
suma += Potega.wynik[i];
}
//WYSZUKANIE MNIEJSZEJ POTEGI
long long wynik;
for(int i = 0; ; i++){
long pot;
pot = Potega.potega(2, i);
if(pot >= suma) { wynik = --i; break; }
}
cout << wynik;
}
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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | #include <iostream> #include <vector> using namespace std; class K{ friend int main(); vector <long long> wynik; public: int potega(int a, int b); int f(int x); int wyszukaj_binarnie(int a, int b); }; int K::potega(int a, int b){ if(b == 0){ return 1; } else{ return a = a * potega(a, --b); } } int main(){ K Potega; vector <int> pot; //WEJSCIE int n; cin >> n; for(int i = 0; i < n; i++){ int k; cin >> k; pot.push_back(k); } //OTRZYMANIE SUMY long long suma = 0; for(int i = 0; i < n; i++){ Potega.wynik.push_back(Potega.potega(2, pot[i])); suma += Potega.wynik[i]; } //WYSZUKANIE MNIEJSZEJ POTEGI long long wynik; for(int i = 0; ; i++){ long pot; pot = Potega.potega(2, i); if(pot >= suma) { wynik = --i; break; } } cout << wynik; } |
English