Description
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.
Sample Input
11 11 5
1
1 #include <iostream> 2 #include<stdio.h> 3 #include<string.h> 4 #include<algorithm> 5 #include<stack> 6 #include<queue> 7 #include<deque> 8 using namespace std; 9 int main() 10 { 11 int i,j,n,ans=0,t,k,ans1=0,m,b,a; 12 scanf("%d%d%d",&a,&b,&n); 13 m=n>b?n:b; 14 k=n>b?b:n; 15 ans=m/a; 16 ans1=k/a; 17 if((ans==0&&ans1==0)) 18 printf("-1 "); 19 else 20 { 21 22 if(m%a!=0&&k<a) 23 printf("-1 "); 24 else 25 printf("%d ",ans+ans1); 26 } 27 return 0; 28 }