Summary

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 835    Accepted Submission(s): 424

Problem Description
Small
W is playing a summary game. Firstly, He takes N numbers. Secondly he
takes out every pair of them and add this two numbers, thus he can get
N*(N - 1)/2 new numbers. Thirdly he deletes the repeated number of the
new numbers. Finally he gets the sum of the left numbers. Now small W
want you to tell him what is the final sum.
 
Input
Multi test cases, every case occupies two lines, the first line contain n, then second line contain n numbers a1, a2, ……an separated by exact one space. Process to the end of file.
[Technical Specification]
2 <= n <= 100
-1000000000 <= ai <= 1000000000
 
Output
For each case, output the final sum.
 
Sample Input
4
1 2 3 4
2
5 5
 
Sample Output
25
10
 
开long long 就好。
#include<iostream>
#include <stdio.h>
#include <algorithm>
using namespace std;
const int N = ;
long long a[N],b[N*N];
int main()
{
int n;
while(scanf("%d",&n)!=EOF){
for(int i=;i<=n;i++){
scanf("%lld",&a[i]);
}
int id = ;
for(int i=;i<=n;i++){
for(int j=i+;j<=n;j++){
b[id++] = a[i]+a[j];
}
}
sort(b,b+id);
long long sum = b[];
for(int i=;i<id;i++){
if(b[i]==b[i-]) continue;
sum=sum+b[i];
}
printf("%lld\n",sum);
}
return ;
}

hdu 4989(水题)的更多相关文章

  1. HDU-1042-N!(Java大法好 &amp;&amp; HDU大数水题)

    N! Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) Total Subm ...

  2. HDU 5391 水题。

    E - 5 Time Limit:1500MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Statu ...

  3. hdu 1544 水题

    水题 /* * Author : ben */ #include <cstdio> #include <cstdlib> #include <cstring> #i ...

  4. HDU排序水题

    1040水题; These days, I am thinking about a question, how can I get a problem as easy as A+B? It is fa ...

  5. hdu 2710 水题

    题意:判断一些数里有最大因子的数 水题,省赛即将临近,高效的代码风格需要养成,为了简化代码,以后可能会更多的使用宏定义,但是通常也只是快速拿下第一道水题,涨自信.大部分的代码还是普通的形式,实际上能简 ...

  6. Dijkstra算法---HDU 2544 水题(模板)

    /* 对于只会弗洛伊德的我,迪杰斯特拉有点不是很理解,后来发现这主要用于单源最短路,稍稍明白了点,不过还是很菜,这里只是用了邻接矩阵 套模板,对于邻接表暂时还,,,没做题,后续再更新.现将这题贴上,应 ...

  7. hdu 5162(水题)

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5162 题解:看了半天以为测试用例写错了.这题玩文字游戏.它问的是当前第i名是原数组中的第几个. #i ...

  8. hdu 3357 水题

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3357 #include <cstdio> #include <cmath> # ...

  9. hdu 5038 水题 可是题意坑

    http://acm.hdu.edu.cn/showproblem.php?pid=5038 就是求个众数  这个范围小 所以一个数组存是否存在的状态即可了 可是这句话真恶心  If not all ...

随机推荐

  1. MTCNN学习进展

    20190618 截止今日,学习了MTCNN预测部分的内容,包括三个网络输入输出之类的东西. 之后需要进一步学习的,NMS原理鞋机,MTCNN训练过程细节,损失函数细节

  2. python3.7 倒计时

    #!/usr/bin/env python __author__ = "lrtao2010" # python3.7 倒计时 import time for i in range( ...

  3. CDOJ:1636-梦后楼台高锁,酒醒帘幕低垂(Kruskal+暴力)

    梦后楼台高锁,酒醒帘幕低垂 Time Limit: 3000/1000MS (Java/Others) Memory Limit: 65535/65535KB (Java/Others) Submit ...

  4. Android开发——常见的内存泄漏以及解决方案(一)

    0. 前言   转载请注明出处:http://blog.csdn.net/seu_calvin/article/details/52333954 Android的内存泄漏是Android开发领域永恒的 ...

  5. POJ 3041 Asteroids (二分图最小点覆盖集)

    Asteroids Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 24789   Accepted: 13439 Descr ...

  6. thinkpad alert键一直处于按着的状态

    就是alert 一直默认按着的,具体原因,我还没有见过. 但是解决方法很简单,crlt+alert一块按,就好了.

  7. python 二——函数、装饰器、生成器、面向对象编程(初级)

    本节内容 1.函数 2.装饰器 3.生成器 4.类 一.函数 函数式:将某功能代码封装到函数中,日后便无需重复编写,仅调用函数即可 面向对象:对函数进行分类和封装,让开发“更快更好更强...” 函数式 ...

  8. laravel5.2总结--数据迁移

          迁移就像是数据库中的版本控制,它让团队能够轻松的修改跟共享应用程序的数据库结构.   1 创建一个迁移 1.1 使用artisan命令make:migration来创建一个新的迁移: ph ...

  9. 在数组中寻找出现次数大于N/K的数

    给定一个int[]数组,给定一个整数k,打印所有出现次数大于N/k的数,没有的话,给出提示信息. === 核心思想:一次在数组中删除K个不同的数,不停的删除,直到剩下的数的种类不足K就停止删除,那么如 ...

  10. java读取文件(更新jdk7及jdk8)

    以字节的方式读取: InputStream inputStream = new FileInputStream(file); int temp = -1; StringBuilder sb = new ...