hdu 2803 The MAX
来源:互联网 发布:人工智能屠宰场小女孩 编辑:程序博客网 时间:2024/03/29 09:02
The MAX
Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2060 Accepted Submission(s): 895
Problem 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
21 20
Sample Output
4017
解题思路:v数组进行从大到小的排序,将最大的元素乘以(2010-n)再加上(n-1)注意的是数组应定义为long long型
#include<stdio.h>#include<algorithm>#include<math.h>using namespace std;long long num[1010];int cmp(long a,long b){return a>b;}int main(){int n;while(scanf("%d",&n),n){for(int i=1;i<=n;i++) { scanf("%lld",&num[i]); } sort(num+1,num+n+1,cmp); long long s=0; s=(2010-n)*num[1]; for(int i=2;i<=n;i++) { s+=num[i]; }printf("%lld\n",s);}return 0;}
0 0
- HDU 2803 The Max
- HDU 2803 The MAX
- hdu 2803 The MAX
- hdu 2803 The MAX
- HDOJ/HDU 2803 The MAX
- 【瞎搞】 HDU 2803 The MAX
- hdu 2803 The MAX【贪心】
- HDU 2803--The MAX【简单数学】
- HDU 2803 The MAX [Ad Hoc]
- hdu--2803 The MAX(sort排序)
- HDU To The Max
- The MAX HDU
- HDU 1081 To the Max
- HDU 1081 To The Max
- HDU 1081 To The Max
- hdu 1081 To The Max
- hdu 1081 to the max
- hdu 1081 To The Max
- C#程序员开发WinForm必须知道的 Window 消息大全
- UVALive 3635-Pie-二分
- 火星人
- qt5.5.1在Cortex-a8上移植记录
- 使用PullToRefresh实现下拉刷新和上拉加载
- hdu 2803 The MAX
- OpenCV函数速查
- Android程序运行的Dalivk和Java程序运行的JVM虚拟机的区别?
- 轮播图的封装(MRC模式,若是ARC模式,需添加Compiler Flags:-fno-objc-arc)
- HDU1856
- 【基础练习】【差分】codevs1242 布局题解
- UISearchBar基本属性
- SpringMVC
- AVPlayer,AVAudioPlayer,语音合成