zoukankan      html  css  js  c++  java
  • hdoj 2803 The MAX【简单规律题】

    The MAX

    Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
    Total Submission(s): 2062    Accepted Submission(s): 896


    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
    2
    1 2
    0
     
    Sample Output
    4017
     
    题解:找到这个数组中最大的数乘以上(2009-n+1)这个数组中其余的数全加上来即可
    #include<stdio.h>
    #include<string.h>
    #include<algorithm>
    #define MAX 110
    #define LL long long
    using namespace std;
    bool cmp(int a,int b)
    {
    	return a>b;
    }
    int main()
    {
    	int n,m,j,i;
    	LL s[MAX];
    	LL sum;
    	while(scanf("%d",&n),n)
    	{
    		sum=0;
    		for(i=0;i<n;i++)
    			scanf("%lld",&s[i]);
    		sort(s,s+n,cmp);
    		for(i=1;i<n;i++)
    		    sum+=s[i];
    		sum+=(s[0]*(2009-n+1));
    		printf("%lld
    ",sum);
    	}
    	return 0;
    } 
    

      

  • 相关阅读:
    sql连接查询中的分类
    HTML之页面镶嵌体验
    JavaScript之搜索框
    (转)Android之常用功能方法大集合
    JAVA之执行cmd命令
    Html之网页分屏浏览
    Javascript之三种按钮点击事件
    用JavaScript做一个小小设计
    JavaBean之简单应用JSP页面
    计算器
  • 原文地址:https://www.cnblogs.com/tonghao/p/4940730.html
Copyright © 2011-2022 走看看