记录编号 |
201742 |
评测结果 |
AAAAAAAAAAAAAAAAAAAA |
题目名称 |
[ZLXOI 2015]殉国 |
最终得分 |
100 |
用户昵称 |
zhzxcool |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.006 s |
提交时间 |
2015-10-31 11:03:45 |
内存使用 |
0.26 MiB |
显示代码纯文本
#include <cstdio>
#include <algorithm>
#define ll long long
using namespace std;
ll gcd(ll x,ll y)
{
if (y == 0) return x;
return gcd(y,x % y);
}
int main()
{
freopen("BlackHawk.in","r",stdin);
freopen("BlackHawk.out","w",stdout);
ll a,b,c;
scanf("%lld%lld%lld",&a,&b,&c);
ll ggg = gcd(a,b);
if (a > b) swap(a,b);
ll lcma = a/ggg;
ll lcmb = b/ggg;
ll minans=0,maxans=0;
ll r1=-1,r2=-1;
for (ll i = 0;i < lcmb;i++)
{
ll tmp = a*i;
if (c-tmp<0) break;
if ((c-tmp)%b == 0)
{
r1 = (c-tmp)/b;
minans = i+(c-tmp)/b;
break;
}
}
for (ll i = 0;i < lcma;i++)
{
ll tmp = b*i;
if (c-tmp<0)break;
if ((c-tmp)%a == 0)
{
r2 = i;
maxans = i+(c-tmp)/a;
break;
}
}
if (r1<0)
puts("-1 -1"),printf("0");
else
{
printf("%lld %lld\n",minans,maxans);
printf("%lld",(r1-r2)/(lcma)+1);
}
fclose(stdin);
fclose(stdout);
return 0;
}