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 ...
随机推荐
- windows下基于IIS配置ssl证书
我这边用的是阿里云的免费证书,下面展示一下操作步骤. 首先登陆阿里云,搜索ssl证书进入ssl证书控制台.点击购买 然后选择免费版,配置如下: 选择立即购买,购买成功后回到ssl控制台即可查看证书.然 ...
- go标准库的学习-fmt
参考https://studygolang.com/pkgdoc 导入方式: import "fmt" mt包实现了类似C语言printf和scanf的格式化I/O.格式化动作(' ...
- 为什么签名前要加"\x19Ethereum Signed Message:\n"
在以太坊中,可以找到关于上述破损的解释例子.以太坊有两种消息,交易
- sysbench数据库压力测试
sysbench是一款压力测试工具,可以测试系统的硬件性能,也可以用来对数据库进行基准测试 wget https://github.com/akopytov/sysbench/archive/1.0. ...
- VsCode源码编译运行
参考链接官方文档:https://github.com/Microsoft/vscode/wiki/How-to-Contribute 一.准备环境 Git Node.js(64位,>= 8.1 ...
- 1029 最大公约数和最小公倍数问题(gcd) luogu洛谷
题目描述 输入22个正整数x_0,y_0(2 \le x_0<100000,2 \le y_0<=1000000)x0,y0(2≤x0<100000,2≤y0<=100 ...
- MATLAB——读取xls文件内容
[NUM,TXT,RAW]=xlsread('example',2,'B2:B261') NUM返回的是excel中的数据, TXT输出的是文本内容, RAW输出的是未处理数据 example:是需要 ...
- MATLAB——sigmoid传递函数
一.log——sigmoid函数 二.tan——sigmoid函数
- 论文列表 for Action recognition
要读的论文: https://www.cnblogs.com/hizhaolei/p/10565405.html 骨架动作识别论文汇总 https://blog.csdn.net/bianxuewei ...
- AI Factorization Machine(FM)算法
FM算法 参考链接: https://www.csie.ntu.edu.tw/~b97053/paper/Rendle2010FM.pdf