记录编号 205030 评测结果 WWWWWAWWAAWWWWAWW
题目名称 [ZLXOI 2015]殉国 最终得分 26
用户昵称 GravatarBinary10 是否通过 未通过
代码语言 C++ 运行时间 0.023 s
提交时间 2015-11-04 19:45:38 内存使用 0.28 MiB
显示代码纯文本
#include<cstdio>
#include<cmath>
using namespace std;
void gcd(int a, int b, int& d, int& x, int& y){
  if(b == 0){ d = a; x = 1; y = 0;}
  else { gcd(b, a % b, d, y, x); y -= x*(a/b);}
}
int main()
{
  freopen("BlackHawk.in", "r", stdin);
  freopen("BlackHawk.out", "w", stdout);
  int a, b, c, d, x, y;
  scanf("%d%d%d", &a, &b, &c);
  gcd(a, b, d, x, y);
  if(c % d != 0) printf("-1 -1\n0\n");
  else {
    int xx = (c / d) * x, yy = (c / d) * y;
    int l = ceil(-(double)xx * d / b), r = floor((double)yy * d / a);
    if(l > r) printf("-1 -1\n0\n");
    else printf("%d %d\n%d\n", l, r, l - r + 1);
  }
  return 0;
}