#include <iostream>
using namespace std;
int potega(int x)
{int sum=1;
while(x>0)
{sum=sum*2;
x--;}
return sum;}
int wyk(long long x)
{int w=0;
while(x>1)
{x=x/2;
w++;}
return w;}
int main()
{
int n;
cin>>n;
int pot[n];
for(int x=0;x<n;x++)
cin>>pot[x];
long long wartosc[n];
for(int a=0;a<n;a++)
wartosc[a]=potega(pot[a]);
int suma=0;
for(int i=0;i<n;i++)
suma=suma+wartosc[i];
int wykl=1;
while(wykl)
{wykl=wykl*2;
if(wykl>=suma)
break;}
if(wykl>suma)
wykl=wykl/2;
cout<<wyk(wykl);
return 0;
}
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 | #include <iostream> using namespace std; int potega(int x) {int sum=1; while(x>0) {sum=sum*2; x--;} return sum;} int wyk(long long x) {int w=0; while(x>1) {x=x/2; w++;} return w;} int main() { int n; cin>>n; int pot[n]; for(int x=0;x<n;x++) cin>>pot[x]; long long wartosc[n]; for(int a=0;a<n;a++) wartosc[a]=potega(pot[a]); int suma=0; for(int i=0;i<n;i++) suma=suma+wartosc[i]; int wykl=1; while(wykl) {wykl=wykl*2; if(wykl>=suma) break;} if(wykl>suma) wykl=wykl/2; cout<<wyk(wykl); return 0; } |
English