URAL 1534 Football in Gondor
来源:互联网 发布:c语言 矩形 rect 编辑:程序博客网 时间:2024/06/09 15:10
#include <stdio.h>long long scoredBalls, missedBalls;long long numOfMatches;long long max, min;int main(){scanf("%lld%lld%lld", &scoredBalls, &missedBalls, &numOfMatches);long long leftScoredBalls, leftMissedBalls;if (scoredBalls >= numOfMatches){//进球数足够多,一共numOfMatches场比赛中有numOfMatches - 1场比赛都是1比0赢了,剩下的唯一的比赛不是赢了就是平了max = 3 * (numOfMatches - 1);leftScoredBalls = scoredBalls - numOfMatches + 1;if (leftScoredBalls > missedBalls){//剩下的一场比赛也赢了max += 3;} else if (leftScoredBalls == missedBalls){//剩下的一场比赛平了max += 1;}} else {//进球数不够多,一共numOfMatches场比赛中有scoredBalls场比赛赢了,剩下的比赛不是输了就是平了max = 3 * scoredBalls;if (missedBalls > 0){//剩下的比赛中有一场输了其他平了max += 1 * (numOfMatches - scoredBalls - 1);} else {//剩下的比赛中全平了max += 1 * (numOfMatches - scoredBalls);}}//类比求最大数的情况if (missedBalls >= numOfMatches){leftMissedBalls = missedBalls - numOfMatches + 1;if (leftMissedBalls < scoredBalls){min += 3;} else if (leftMissedBalls == scoredBalls){min += 1;}} else {if (scoredBalls > 0){min += 3;min += 1 * (numOfMatches - missedBalls - 1);} else {min += 1 * (numOfMatches - missedBalls);}}//坑,进球和失球都在一场比赛,其他比赛都是平局 long long tempMin = 1 * (numOfMatches - 1);if (scoredBalls > missedBalls){tempMin += 3;} else if (scoredBalls == missedBalls){tempMin += 1;}//例如输入是2 2 2的情况,这样算出来的tempMin会比min更小if (tempMin < min){min = tempMin;}printf("%lld %lld\n", max, min);return 0;}
0 0
- URAL 1534 Football in Gondor
- ural 1874 Football Goal
- Ural 1874 Football Goal
- URAL 1874 Football Goal 均值不等式&三分
- timus 1874. Football Goal URAL 解题报告 计算几何
- URAL 1874. Football Goal(数学 浮点数三分)
- Football
- Football
- Football
- Football
- Football
- Football
- URAL 1025. Democracy in danger
- ural 1025 Democracy in Danger
- ural 1905 Travel in Time
- URAL 1314. Chase in Subway
- Ural 1962 In Chinese Restaurant
- URAL 1785 Lost in Localization
- LP---精益生产(Lean Production)
- 自己在拖xib中遇到的一些小问题
- Barcode Reader SDK使用教程:网络摄像机读取条码
- LeetCode Integer to Roman
- MP4文件格式详解——元数据moov(一)mvhd box(转)
- URAL 1534 Football in Gondor
- KNN的Python实现(需添加库numpy和operator)
- 网络虚拟化技术(一): Linux网络虚拟化
- Linux命令整理--pwd命令
- <iOS>swift简单控件的创建
- c++存取dat数据
- FileZilla FTP Server在win2008安装及防火墙设置
- leetcode-Power of Two
- c++单例