比赛 |
ZLXOI2015Day1 |
评测结果 |
AAATAAATAW |
题目名称 |
殉国 |
最终得分 |
70 |
用户昵称 |
Binary10 |
运行时间 |
2.370 s |
代码语言 |
C++ |
内存使用 |
0.31 MiB |
提交时间 |
2015-10-29 11:54:36 |
显示代码纯文本
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<cmath>
#include<cctype>
#include<cstdio>
#include<string>
#include<vector>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
const int INF = 0x3f3f3f3f;
void gcd(int a, int b, int& d, int& x, int& y){
if(!b){ 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;
cin >> a >> b >> c;
gcd(a, b, d, x, y); // TMD 不会做了
if(c % d != 0){
printf("-1 -1\n0\n");
return 0;
}
int cnt = 0, minn = INF, maxn = 0;
for(int x = 0; x <= c / a; x++)
for(int y = 0; y <= c / a && a * x + b *y <= c; y++)
if(a * x + b * y == c){
cnt++;
minn = min(minn, x + y);
maxn = max(maxn, x + y);
}
if(cnt == 0) minn = maxn = -1;
printf("%d %d\n%d\n", minn, maxn, cnt);
return 0;
}