博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
poj2549--Sumsets (sum)
阅读量:7184 次
发布时间:2019-06-29

本文共 1308 字,大约阅读时间需要 4 分钟。

Sumsets
Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 9983   Accepted: 2731

Description

Given S, a set of integers, find the largest d such that a + b + c = d where a, b, c, and d are distinct elements of S.

Input

Several S, each consisting of a line containing an integer 1 <= n <= 1000 indicating the number of elements in S, followed by the elements of S, one per line. Each element of S is a distinct integer between -536870912 and +536870911 inclusive. The last line of input contains 0.

Output

For each S, a single line containing d, or a single line containing "no solution".

Sample Input

52 3 5 7 1252 16 64 256 10240

Sample Output

12no solution

Source

 
转化成 a+b=c-d;
#include 
#include
#define M 1010using namespace std;int num[M];int main(){ int n; while(scanf("%d", &n) != EOF &&n!=0) { for(int i=0; i
=0; i--) { for(int j=n-1; j>=0; j--) { if(i==j) continue; int multiply=num[i]-num[j]; int rear=0, top= j-1; //注意 top取值范围 ; while(rear
num[rear]+num[top]) rear++; if(multiply

 

转载于:https://www.cnblogs.com/soTired/p/5326075.html

你可能感兴趣的文章
是什么优化让 .NET Core 性能飙升?
查看>>
blog与log
查看>>
《统一沟通-微软-实战》-7-配置-2-呼叫寄存
查看>>
手机APP,台前幕后在争啥?
查看>>
DPM存储池对磁盘的要求
查看>>
SCOM 2012知识分享-13:搜索功能
查看>>
Exchange Server 2016管理系列课件32.传输规则部署免责声明
查看>>
SQL Server 备份与恢复之四:备份类型和选项
查看>>
字母个数统计程序示例
查看>>
Hadoop运维记录系列(十二)
查看>>
React Native基础&入门教程:以一个To Do List小例子,看props和state
查看>>
EonerCMS——做一个仿桌面系统的CMS(一)
查看>>
Clustering of Multivariate data 多源数据的聚类
查看>>
IE9最终版透露IE10信息 或将自动在线升级
查看>>
魔兽争霸自定义地图解释器存在安全漏洞
查看>>
部分Gamefest 2011的材料已经放出
查看>>
在Linux下安装Tomcat 5.5
查看>>
Translate_Windows_Program_via_C_____The How to Build Guide with VS 9.0/2008
查看>>
VMWare7和RHEL6共享上网的几个小问题
查看>>
LiteORM学习六:远程对象
查看>>