题目链接:
https://cn.vjudge.net/problem/HDU-1495
题目大意:
给出三个数 S N M
分别表示可乐的体积 俩个杯子的容量,要求你用着俩个杯子去平均可乐,最后能喝到两杯体积一样的可乐,问最少要倒的次数,不能平分输出 NO
样例:
7 4 3
4 1 3
0 0 0
输出:
NO
3
代码:
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <math.h>
#include <iomanip>
using namespace std;
typedef long long ll;
int a,b,c;
int step=1;
int main()
{
while(scanf("%d %d %d",&a,&b,&c)!=EOF)
{
if(a==0&&b==0&&c==0)
{
return 0;
}
a/=__gcd(b,c);
if(a%2==0)
{
cout<<a-1<<endl;
}
else
{
cout<<"NO"<<endl;
}
}
}