A. Make a triangle!
题意
给你三条边a,b,c问使得构成三角形,需要增加的最少长度是多少
思路
数学了啦
代码
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
//freopen("in.txt","r",stdin);
int a,b,c;
while(cin>>a>>b>>c){
if(a+b>c&&a+c>b&&b+c>a)
{
cout<<0<<endl;
continue;
}
int i=a+b-c,j=a+c-b,k=b+c-a;
int h=min(i,min(j,k));
if(h<=0) cout<<-h+1<<endl;
}
return 0;
}
A. Make a triangle!的更多相关文章
- [LeetCode] Triangle 三角形
Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent n ...
- [LeetCode] Pascal's Triangle II 杨辉三角之二
Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3,Return [1,3, ...
- [LeetCode] Pascal's Triangle 杨辉三角
Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5,Retur ...
- 【leetcode】Pascal's Triangle II
题目简述: Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3, Retur ...
- 【leetcode】Pascal's Triangle
题目简述: Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5 ...
- POJ 1163 The Triangle(简单动态规划)
http://poj.org/problem?id=1163 The Triangle Time Limit: 1000MS Memory Limit: 10000K Total Submissi ...
- Triangle - Delaunay Triangulator
Triangle - Delaunay Triangulator eryar@163.com Abstract. Triangle is a 2D quality mesh generator an ...
- LeetCode 118 Pascal's Triangle
Problem: Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows ...
- LeetCode 119 Pascal's Triangle II
Problem: Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3,Ret ...
- 【leetcode】Triangle (#120)
Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent n ...
随机推荐
- git撤销本地提交但未push的记录
### git撤销本地提交但未push的记录 前言:有时候本地执行commit命令或者cherry-pick命令后发现提交了不需要提交的东西,就需要把已提交的commit记录撤销下来,简单做下记录 撤 ...
- windows防火墙安全设置指定ip访问指定端口
场景摘要: 1.我有三台腾讯云服务器 2.我日常办公网络的ip换了 3.我在腾讯云上面改了安全规则,也不能访问我A服务器的21,1433等端口 4.开始我以为是办公网络的安全设置问题 5.我进B服务器 ...
- ccf--20150903--模板生成系统
本题思路:首先,使用一个map来存储所有需要替换的关键词,然后,再逐行的替换掉其中的关键词,记住,find每次的其实位置不一样,否则会出现递归生成没有出现关键词就清空掉.最后输出. 题目和代码如下: ...
- ASP.NET WebForm 检测页面刷新(Refresh)
本文是翻译贴, 原文参见Detecting browser 'Refresh' from Code behind in C# 浏览器的"刷新"常会导致问题, 特别是当页面和数据库有 ...
- Lua 与 C 交互值 函数调用(2)
@(语言) Lua和C 函数间的使用,都是通过栈来交互,并且基于遵守一定的规则,按照这个规则来就可以了. 1. 调用Lua函数 调用Lua方法过程 将被调用的函数入栈: 依次将所有参数入栈: 使用 l ...
- Static简介
1.static称为静态修饰符,它可以修饰类中得成员.被static修饰的成员被称为静态成员,也成为类成员,而不用static修饰的成员称为实例成员. 2.当 Voluem volu1 = new V ...
- python六十课——高阶函数之map
1.高阶函数: 特点:函数的形参位置必须接受一个函数对象 分类学习: 1).map(fn,lsd1,[lsd2...]): 参数一:fn --> 函数对象 参数二:lsd1 --> 序列对 ...
- 30个你 “ 不可能全部会做 ” 的javascript题目
1,以下表达式的运行结果是: ["1","2","3"].map(parseInt) A.["1","2&qu ...
- day16 Python 函数嵌套函数和作用域
#函数的作用域只跟函数声明时定义的作用域有关,跟函数的调用位置无任何关系 name = 'alex' def foo(): name='linhaifeng' def bar(): #name='wu ...
- 表情存储异常--mybatis抛出异常(java.sql.SQLException: Incorrect string value: '\xF0\x9F\x92\x94' for column 'name' at row 1)
文章参考 https://blog.csdn.net/junsure2012/article/details/42171035 https://www.cnblogs.com/WangYunShuai ...