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 ...
随机推荐
- Hive-1.2.1_01_安装部署
前言:该文章是基于 Hadoop2.7.6_01_部署 进行的. 1. Hive基本概念 1.1. 什么是Hive Hive是基于Hadoop的一个数据仓库工具,可以将结构化的数据文件映射为一张数据库 ...
- oracle用户权限和角色
用户权限是最基本的数据库安全控制.其作用就是控制用户对数据的访问,sql语句的执行.当oracle用户创建的时候,可以通过授权来控制用户对数据的连接,数据库对象的操作等等. 在oracle中,分为两种 ...
- Weblogic读不到Word文件
之前遇到一导出word文件的需求,我的做法是把对应导出内容放到一个word文件中,把其中变化的内容作为变量,然后把该word文件放在WEB-INF目录下用来作为模板.在导出时通过ServletCont ...
- 使用k8s cronjob ,清除应用生成的日志文件
目前应用日志,tomcat日志 统一输出到 /data/logs/pod名字/ 目录下,并且/data/logs 目录挂载到cephfs上, tomcat 日志使用 cronolog进行日志切割 使用 ...
- usb-cam(1)安装
http://www.liuxiao.org/2015/10/ros-%E5%AE%89%E8%A3%85-usb-camera-%E9%A9%B1%E5%8A%A8%E5%B9%B6%E8%B0%8 ...
- CentOS 7.x编译安装Nginx1.10.3+MySQL5.7.16+PHP5.2 5.3 5.4 5.5 5.6 7.0 7.1多版本全能环境
准备篇 一.防火墙配置 CentOS 7.x默认使用的是firewall作为防火墙,这里改为iptables防火墙. 1.关闭firewall: systemctl stop firewalld.se ...
- Dubbo高级篇4
https://blog.csdn.net/moonpure/article/details/52842115 线程模型 http://dubbo.io/User+Guide-zh.htm 用户指南& ...
- PAT A1139 First Contact (30 分)——set
Unlike in nowadays, the way that boys and girls expressing their feelings of love was quite subtle i ...
- MySQL 基础十 性能优化
1.优化sql 2.建立索引 3.优化表结构,避免多个join查询
- exBSGS·BSGS-Senior/扩展的BSGS
\(\rm{0x01\quad Preface}\) \(emmm\)严格来讲,不应该被算到一个模板里面.因为在我看来模板是人构造出来的,但是这个算法应该是一个解决问题的\(process\)-更像是 ...