評分結果(參考) : AC (1ms, 304KB)
#include<bits/stdc++.h>
#define int long long
using namespace std;
vector<int> productCnt(7);
bool canFit(int width){
vector<int> v(7);
for(int i=0; i<=6; i++){
v[i] = width/(1<<i);
v[i] *= v[i];
}
for(int i=6; i>=0; i--){
if(v[i] < productCnt[i]) return false;
for(int j=i; j>=0; j--){
v[j] -= (1LL<<(2*(i-j))) * productCnt[i];
}
}
return true;
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
while(true){
cin >> productCnt[0];
if(productCnt[0] == -1) break;
for(int i=1; i<=6; i++){
cin >> productCnt[i];
}
int l=0, r=1e9;
while(l < r){
int m = (l+r)/2;
if(canFit(m)) r = m;
else l = m+1;
}
cout << l << "\n";
}
return 0;
}