SOJ.Sum Fun

12985. Sum Fun

限制条件

时间限制: 1 秒, 内存限制: 256 兆

题目描述

Given a list of 3 positive integers, it may or may not be true that one of those numbers is the sum of the other two. Given several such sets of 3 positive integers, either output the equation that shows that one number can be written as the sum of the other
two, or indicate that there is no sum.

输入格式

The input begins with an integer T (T<=10), indicating the number of test cases. The following T lines each contain exactly 3 space-separated positive integers. Each integer is less than or equal to 100.

输出格式

If one of the numbers can be written as the sum of the other two, then write the equation as shown below (the two that can be added to make the third should be output in the same order that they appeared in the input). Note that a space separates each number
from each symbol in the equation. If no such sum can be made, output the three numbers in their original order, followed by a space, followed by the words NO SUM. Format your output as shown below.

样例输入

3
4 12 8
3 2 1
6 12 5

样例输出

4 + 8 = 12
2 + 1 = 3
6 12 5 NO SUM

提示

提示:请注意输出式子中的空格.

题目来源

2014年每周一赛第十五场暨“指点传媒杯”第六届中山大学ICPC新手赛模拟赛

时间: 2024-11-05 19:41:08

SOJ.Sum Fun的相关文章

soj 1034 Forest_求树的深度和宽度

题目链接 题意:给你n个节点,m条边,每条边是有向的,这颗树不能有自环,问这颗树的深度和宽度 思路: 不合法情况 1,入度大于1,即存在两条指向同一顶点的边 2,一条入点和出点都相同的边 3,一条变得入点和出点深度已知,但不符合出点的深度是入点的深度加1 4,点入深度未知但出点深度已知 5,遍历完以后,有顶点未遍历,说明有多个根 树的宽度是指,同一层最多有多少个节点 #include <iostream> #include<cstdio> #include<cstring&g

分段动态规划(SOJ 1162)

SOJ 1162: I-Keyboard http://acm.scu.edu.cn/soj/problem.action?id=1162 Given a string $S$ with length $L$ in which each character has a frequency $F[i], 0\le i<L$, the target is to partition $S$ into $K$ segments satisfying that the sum of products is

单调栈(SOJ 3085)

SOJ 3085: windy's cake V http://acm.scu.edu.cn/soj/problem.action?id=3085 Problem: Given a list of $n$ positive integers $num[1], ..., num[n]$, denote the score of one sublist from $i$ to $j$ as $(\min_{i\le k\le j}num[k])*\left(\Sigma_{k=i}^{j}num[k

LeetCode OJ - Sum Root to Leaf Numbers

这道题也很简单,只要把二叉树按照宽度优先的策略遍历一遍,就可以解决问题,采用递归方法越是简单. 下面是AC代码: 1 /** 2 * Sum Root to Leaf Numbers 3 * 采用递归的方法,宽度遍历 4 */ 5 int result=0; 6 public int sumNumbers(TreeNode root){ 7 8 bFSearch(root,0); 9 return result; 10 } 11 private void bFSearch(TreeNode ro

129. Sum Root to Leaf Numbers

Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number. An example is the root-to-leaf path 1->2->3 which represents the number 123. Find the total sum of all root-to-leaf numbers. For example, 1 / 2 3 T

Leetcode 494 Target Sum 动态规划 背包+滚动数据

这是一道水题,作为没有货的水货楼主如是说. 题意:已知一个数组nums {a1,a2,a3,.....,an}(其中0<ai <=1000(1<=k<=n, n<=20))和一个数S c1a1c2a2c3a3......cnan = S, 其中ci(1<=i<=n)可以在加号和减号之中任选. 求有多少种{c1,c2,c3,...,cn}的排列能使上述等式成立. 例如: 输入:nums is [1, 1, 1, 1, 1], S is 3. 输出 : 5符合要求5种

31.SUM() 函数

SUM() 函数 SUM 函数返回数值列的总数(总额). SQL SUM() 语法 SELECT SUM(column_name) FROM table_name SQL SUM() 实例 我们拥有下面这个 "Orders" 表: O_Id OrderDate OrderPrice Customer 1 2008/12/29 1000 Bush 2 2008/11/23 1600 Carter 3 2008/10/05 700 Bush 4 2008/09/28 300 Bush 5

1305 Pairwise Sum and Divide

基准时间限制:1 秒 空间限制:131072 KB 分值: 5 难度:1级算法题 有这样一段程序,fun会对整数数组A进行求值,其中Floor表示向下取整: fun(A) sum = 0 for i = 1 to A.length for j = i+1 to A.length sum = sum + Floor((A[i]+A[j])/(A[i]*A[j])) return sum 给出数组A,由你来计算fun(A)的结果.例如:A = {1, 4, 1},fun(A) = [5/4] + [

Java [Leetcode 303]Range Sum Query - Immutable

题目描述: Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive. Example: Given nums = [-2, 0, 3, -5, 2, -1] sumRange(0, 2) -> 1 sumRange(2, 5) -> -1 sumRange(0, 5) -> -3 Note: You may assume that the ar