Blankj's Blog

select * from utils


  • 首页

  • 关于

  • 分类

  • 标签

  • 归档

  • 我的星球

  • 面经

  • 我的开源库

  • Go 速查

  • GitBook

  • 小伙伴们

  • 内推

  • 搜索

Additive equations

发表于 2015-01-04 | 分类于 OJ | 阅读次数:

题目描述

We all understand that an integer set is a collection of distinct integers. Now the question is: given an integer set, can you find all its addtive equations? To explain what an additive equation is, let’s look at the following examples:
1+2=3 is an additive equation of the set {1,2,3}, since all the numbers that are summed up in the left-hand-side of the equation, namely 1 and 2, belong to the same set as their sum 3 does. We consider 1+2=3 and 2+1=3 the same equation, and will always output the numbers on the left-hand-side of the equation in ascending order. Therefore in this example, it is claimed that the set {1,2,3} has an unique additive equation 1+2=3.
It is not guaranteed that any integer set has its only additive equation. For example, the set {1,2,5} has no addtive equation and the set {1,2,3,5,6} has more than one additive equations such as 1+2=3, 1+2+3=6, etc. When the number of integers in a set gets large, it will eventually become impossible to find all the additive equations from the top of our minds – unless you are John von Neumann maybe. So we need you to program the computer to solve this problem.

阅读全文 »
1…1617
布兰柯基

布兰柯基

161 日志
38 分类
85 标签
GitHub 简书 掘金 CSDN 微博
0%
© 2021 布兰柯基