C. Table Tennis Game 2
来源:互联网 发布:mac电脑word储存位置 编辑:程序博客网 时间:2024/04/29 05:22
Misha and Vanya have played several table tennis sets. Each set consists of several serves, each serve is won by one of the players, he receives one point and the loser receives nothing. Once one of the players scores exactly k points, the score is reset and a new set begins.
Across all the sets Misha scored a points in total, and Vanya scored b points. Given this information, determine the maximum number of sets they could have played, or that the situation is impossible.
Note that the game consisted of several complete sets.
The first line contains three space-separated integers k, a and b (1 ≤ k ≤ 109, 0 ≤ a, b ≤ 109, a + b > 0).
If the situation is impossible, print a single number -1. Otherwise, print the maximum possible number of sets.
11 11 5
1
11 2 3
-1
Note that the rules of the game in this problem differ from the real table tennis game, for example, the rule of "balance" (the winning player has to be at least two points ahead to win a set) has no power within the present problem.
题目链接:http://codeforces.com/contest/765/problem/C
英语不好真是坑死人啊,一开始读错了题,硬推了一个多小时敲了个代码,错了,然后又读题,这次没读错,但是写成了最小,我的天。
题目的意思是说两个人玩游戏,最终两个人的得分为a,b,当两个人的得分为k时开下一场,问最多经过几场比赛,读懂题之后秒A,一遍过。。。我的内心¥……*!@#¥……&*
代码:
#include <cstdio>#include <cstring>#include <iostream>using namespace std;int main(){ long long a,b,k; cin>>k>>a>>b; if(a<b){ a=a^b; b=a^b; a=a^b; } if(a<k&&b<k){ cout<<"-1"<<endl; } else if(a%k&&b<k){ cout<<"-1"<<endl; } else{ long long sum=a/k; sum+=(b/k); cout<<sum<<endl; } return 0;}
- C. Table Tennis Game 2
- C. Table Tennis Game 2
- 【codeforces 765C】Table Tennis Game 2
- CF 397 C. Table Tennis Game 2
- 765C Table Tennis Game 2
- Table Tennis Game 2
- 【Codeforces 765 C. Table Tennis Game 2】+ 贪心
- Codeforces Round #397 - Problem C - Table Tennis Game 2
- C. Table Tennis Game 2 Codeforces Round #397
- Codeforces Round #397(Div. 1 + Div. 2 combined)C. Table Tennis Game 2【贪心】
- Table Tennis
- Table tennis
- Table Tennis
- 1795. Table tennis
- 1422. Table Tennis
- sicily--1795. Table tennis
- 1026. Table Tennis (30)
- 1795[Table Tennis]
- Android屏幕适配全攻略(最权威的官方适配指导)
- API2 下面 FW/HAL 框架结构
- [题解]bzoj1507(NOI2003)Editor
- 文章标题
- 服务器端开发常用的linux命令总结
- C. Table Tennis Game 2
- Hadoop之—— WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform...
- ssm配置文件(一) ——web.xml配置
- 解决XCode编译异常clang: error: linker command failed with exit code 1
- 行成于思,孜孜不倦-半年总结
- opencv之imwrite函数使用
- JSP九大内置对象及四个作用域
- 数据结构实验之栈六:下一较大值(二)
- 建造者模式