国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學(xué)院 > 開發(fā)設(shè)計 > 正文

【Codeforces 765 C. Table Tennis Game 2】+ 貪心

2019-11-08 20:16:16
字體:
供稿:網(wǎng)友

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

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.

乒乓球賽,其中一方達到k分,分數(shù)清零后重新開始下一場,給出兩個人比賽了n場后的最終總得分a,b,最多比賽了多少場,若給出的a,b不合法輸出-1

AC代碼:

#include<cstdio>int main(){ int k,a,b; scanf("%d %d %d",&k,&a,&b); printf((a % k && b / k == 0) || (b % k && a / k == 0) ? "-1/n" : "%d/n",a / k + b / k); return 0;}
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 扎囊县| 图们市| 和林格尔县| 道真| 理塘县| 多伦县| 黄陵县| 锡林浩特市| 龙井市| 恩施市| 绿春县| 来宾市| 平果县| 茂名市| 东兴市| 淄博市| 新田县| 上虞市| 奇台县| 宜都市| 阿克陶县| 凤庆县| 获嘉县| 南京市| 中山市| 酒泉市| 泰顺县| 油尖旺区| 天峨县| 淳安县| 射阳县| 冀州市| 沿河| 岑巩县| 湖北省| 鹿泉市| 望奎县| 徐闻县| 乐业县| 苍山县| 青岛市|