#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <ctime>
#include <list>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iostream>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
const int amount = 5000000 ;
using namespace std ;
int main()
{
vector <int> jak ;
int test ;
cin>>test ;
while(test--)
{
int n ;
while(cin>>n)
{
if(n==0)
break ;
jak.push_back(n) ;
}
sort(jak.begin(), jak.end()) ;
int len = jak.size() ;
int l = len ; long int k=0,j=1 ;
for(int i=len-1 ; i>=0; i--)
{
k = k+ (2 *pow(jak[i],j) ) ;
j++ ;
}
if(k>amount)
printf("Too expensive\n") ;
else
printf("%d\n",k) ;
jak.clear() ;
}
return 0 ;
}
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <ctime>
#include <list>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iostream>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
const int amount = 5000000 ;
using namespace std ;
int main()
{
vector <int> jak ;
int test ;
cin>>test ;
while(test--)
{
int n ;
while(cin>>n)
{
if(n==0)
break ;
jak.push_back(n) ;
}
sort(jak.begin(), jak.end()) ;
int len = jak.size() ;
int l = len ; long int k=0,j=1 ;
for(int i=len-1 ; i>=0; i--)
{
k = k+ (2 *pow(jak[i],j) ) ;
j++ ;
}
if(k>amount)
printf("Too expensive\n") ;
else
printf("%d\n",k) ;
jak.clear() ;
}
return 0 ;
}
No comments:
Post a Comment