比赛 防止浮躁的小练习v0.9 评测结果 AAAAAAAAAAAAAAAAAAAA
题目名称 殉国 最终得分 100
用户昵称 rewine 运行时间 0.050 s
代码语言 C++ 内存使用 0.23 MiB
提交时间 2016-11-07 08:16:30
显示代码纯文本
#include <cstdio>
#include <iostream>
#include <cstring>

using namespace std; 
typedef long long lg;
#define int long long
lg m,s,l,r;
 
void exgcd(int a,int b,int &x,int &y,int &g) {
	if(b == 0) {
		x = 1; y = 0; g = a;
		return;
	}
	exgcd(b,a%b,x,y,g);
	int tmp = x;
	x = y;
	y = tmp-a/b*y;
}
 
int x,y,g,sum = 0;
lg a,b,c,a1,a2;
void work() {
	cin >> a >> b >> c;
	exgcd(a,b,x,y,g);
	if(c % g) {
		cout << ("-1 -1\n0");
		return;
	}
	int mul = c /= g;
	x *= mul; y *= mul;
	b = b/g ;a = a/g;
	int xx = x,yy = y;
	xx = (xx%b+b)%b;
	yy = (c-xx*a)/b;
	if(yy < 0) {
		cout << ("-1 -1\n0");
    	return;
	}
	y = (y%a+a)%a;
    x = (c-y*b)/a;
    if(x < 0) {
    	 cout << ("-1 -1\n0");
    	 return;
	}
	sum = (x-xx)/b+1;
    cout << min(xx+yy,x+y) << " " << max(xx+yy,x+y) << "\n" << sum;
}
 
signed main() {
	freopen("BlackHawk.in","r",stdin);
	freopen("BlackHawk.out","w",stdout);
    work();
	return 0;
}