CF1064A Make a triangle!

    • 162通过
    • 183提交
  • 题目来源 CodeForces 1064A
  • 评测方式 RemoteJudge
  • 标签
  • 难度 普及-
  • 时空限制 2000ms / 256MB

题解

  • 提示:收藏到任务计划后,可在首页查看。
  • 体验新版界面

    最新讨论 显示

    推荐的相关题目 显示

    题意翻译

    题目描述

    Masha有三根长度分别为a,b,c厘米的小棒。每一分钟,Masha可以选择一根小棒并将它的长度增加一厘米,但他不可以折断小棒。 现在他要你求出他最少需要多少时间使得这三根小棒可以构成一个三角形。

    输入格式

    三个数,分别为a,b,c

    输出格式

    一个数,为Masha最少需要的时间

    题目描述

    Masha has three sticks of length $ a $ , $ b $ and $ c $ centimeters respectively. In one minute Masha can pick one arbitrary stick and increase its length by one centimeter. She is not allowed to break sticks.

    What is the minimum number of minutes she needs to spend increasing the stick's length in order to be able to assemble a triangle of positive area. Sticks should be used as triangle's sides (one stick for one side) and their endpoints should be located at triangle's vertices.

    输入输出格式

    输入格式:

    The only line contains tree integers $ a $ , $ b $ and $ c $ ( $ 1 \leq a, b, c \leq 100 $ ) — the lengths of sticks Masha possesses.

    输出格式:

    Print a single integer — the minimum number of minutes that Masha needs to spend in order to be able to make the triangle of positive area from her sticks.

    输入输出样例

    输入样例#1: 复制
    3 4 5
    
    输出样例#1: 复制
    0
    
    输入样例#2: 复制
    2 5 3
    
    输出样例#2: 复制
    1
    
    输入样例#3: 复制
    100 10 10
    
    输出样例#3: 复制
    81
    

    说明

    In the first example, Masha can make a triangle from the sticks without increasing the length of any of them.

    In the second example, Masha can't make a triangle of positive area from the sticks she has at the beginning, but she can spend one minute to increase the length $ 2 $ centimeter stick by one and after that form a triangle with sides $ 3 $ , $ 3 $ and $ 5 $ centimeters.

    In the third example, Masha can take $ 33 $ minutes to increase one of the $ 10 $ centimeters sticks by $ 33 $ centimeters, and after that take $ 48 $ minutes to increase another $ 10 $ centimeters stick by $ 48 $ centimeters. This way she can form a triangle with lengths $ 43 $ , $ 58 $ and $ 100 $ centimeters in $ 81 $ minutes. One can show that it is impossible to get a valid triangle faster.

    提示
    标程仅供做题后或实在无思路时参考。
    请自觉、自律地使用该功能并请对自己的学习负责。
    如果发现恶意抄袭标程,将按照I类违反进行处理。