Description
Giving N integers, V1, V2,,,,Vn, you should find the biggest value of F.
Input
Each test case contains a single integer N (1<=N<=100). The next line contains N integers, meaning the value of V1, V2....Vn.(1<= Vi <=10^8).The input is terminated by a set starting with N = 0. This set should not be processed.
Output
For each test case, output the biggest value of F you can find on a line.
Sample Input
2 1 2 0
Sample Output
4017
这题真是叫人无语了,给的数据值根本就不对,竟然是long long的,不是说10的8次方吗?有这样坑人的水题吗?
AC代码:
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
unsigned long long k,j,n,i,a[110];
while(cin >> n&&n)
{
for(i=0,j=0;i<n;++i)
{
cin >> a[i];
j+=a[i];
}
sort(a,a+n);
j-=a[n-1];
k=a[n-1]*(2009-n+1)+j;
cout << k << endl;
}
return 0;
}