记录编号 |
201228 |
评测结果 |
AAAAAAAAAAAAAAAAAAAA |
题目名称 |
[ZLXOI 2015]殉国 |
最终得分 |
100 |
用户昵称 |
KZNS |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.005 s |
提交时间 |
2015-10-30 12:00:50 |
内存使用 |
0.31 MiB |
显示代码纯文本
// KZ's
#include <fstream>
using namespace std;
typedef long long ll;
ll exgcd(ll a,ll b,ll &x,ll &y) {
if(!a) {
x=0;
y=1;
return b;
}
ll d=exgcd(b%a,a,y,x);
x-=b/a*y;
return d;
}
int main() {
ifstream fin ("BlackHawk.in");
ofstream fout ("BlackHawk.out");
ll a,b,c,x0,y0;
fin>>a>>b>>c;
ll d=exgcd(a,b,x0,y0);
if (c%d) {
fout<<"-1 -1\n0\n";
return 0;
}
a/=d;
b/=d;
c/=d;
x0*=c;
y0*=c;
ll tl,tr;
if (x0<0)
tl=(-x0+b-1)/b;
else
tl=-x0/b;
if (y0<0)
tr=(y0-a+1)/a;
else
tr=y0/a;
if (tr<tl) {
fout<<"-1 -1\n0\n";
return 0;
}
if (a>b)
fout<<x0+y0+(b-a)*tr<<' '<<x0+y0+(b-a)*tl<<endl<<tr-tl+1<<endl;
else
fout<<x0+y0+(b-a)*tl<<' '<<x0+y0+(b-a)*tr<<endl<<tr-tl+1<<endl;
return 0;
}
// UBWH