C. Table Tennis Game 2
2017-02-14 21:23
393 查看
C. Table Tennis Game 2
time limit per test
2 seconds
memory limit per test
512 megabytes
input
standard input
output
standard output
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.
Input
The first line contains three space-separated integers k, a and b (1 ≤ k ≤ 109, 0 ≤ a, b ≤ 109, a + b > 0).
Output
If the situation is impossible, print a single number -1. Otherwise, print the maximum possible number of sets.
Examples
input
output
input
output
Note
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;
}
time limit per test
2 seconds
memory limit per test
512 megabytes
input
standard input
output
standard output
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.
Input
The first line contains three space-separated integers k, a and b (1 ≤ k ≤ 109, 0 ≤ a, b ≤ 109, a + b > 0).
Output
If the situation is impossible, print a single number -1. Otherwise, print the maximum possible number of sets.
Examples
input
11 11 5
output
1
input
11 2 3
output
-1
Note
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;
}
相关文章推荐
- TypeScript和JavaScript哪种语言更先进
- 图像处理基础(3):均值滤波器及其变种
- lambda
- Python的递归
- HADOOP_CLASSPATH配置问题
- Linux编程之ICMP洪水攻击
- hadoop基本介绍及简单安装配置
- 蓝桥杯算法提高 概率计算
- BZOJ 1036: [ZJOI2008]树的统计Count
- cassandra vs mongo (1)存储引擎
- C语言 · 完数
- 利用IIS应用请求转发ARR实现IIS和tomcat整合共用80端口
- 索引类型及其区别
- JavaScript作用域链
- 宇宙总统
- 2 itk安装记录
- angular.js和ionic框架搭建一个webApp
- vim与gcc
- dfs带状态改变的做法
- android 点击缩略图查看大图