CodeForces

来源:互联网 发布:nba2k17麦迪动作数据 编辑:程序博客网 时间:2024/06/06 09:46
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 ka and b (1 ≤ k ≤ 1090 ≤ a, b ≤ 109a + 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


小细节题:

#include<stdio.h>#include<string.h>using namespace std;int main(){    int k,n,m;    while(~scanf("%d%d%d",&k,&n,&m))    {        int res=0;        res+=(n/k);        res+=(m/k);        if(n%k&&m<k||(m%k&&n<k))        {            printf("-1\n");            continue;        }        if(res)            printf("%d\n",res);        else printf("-1\n");    }}


原创粉丝点击