#include <bits/stdc++.h> using namespace std; int main () { int n; unsigned long long x=1; int y=0; unsigned long long d; unsigned long long suma=0; cin>>n; int a; for(int i=0; i<n; ++i) { d=1; cin>>a; for(int j=0; j<a; ++j) d=d*2; suma+=d; } while(x<=suma) { y++; x=x*2; } y--; cout<<y<<endl; }
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 | #include <bits/stdc++.h> using namespace std; int main () { int n; unsigned long long x=1; int y=0; unsigned long long d; unsigned long long suma=0; cin>>n; int a; for(int i=0; i<n; ++i) { d=1; cin>>a; for(int j=0; j<a; ++j) d=d*2; suma+=d; } while(x<=suma) { y++; x=x*2; } y--; cout<<y<<endl; } |