Baby Ming and Weight lifting(BestCoder)
来源:互联网 发布:大数据培训班多少钱 编辑:程序博客网 时间:2024/05/29 09:33
纯暴力,做的时候太心急了错了两遍。。
#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>#include <cstdlib>#include <queue>using namespace std;const int maxn = 100010;int T, n;int main() { scanf("%d", &T); while(T--) { int a, b, c; scanf("%d%d%d", &a, &b, &c); int ans = 10000000; int A, B; bool ok = false; for(int i = 0; i <= c; ++i) { int num = (c - i * a) / b; if(i * a + b * num == c) { bool is = false; for(int j = 0; j <= i; ++j) { for(int k = 0; k <= num; ++k) { if(j * a + k * b == c - j * a - k * b) { is = true; goto leap; } } } leap: if(is && ans > i + num) { A = i; B = num; ans = i + num; ok = true; } } } if(!ok) printf("Impossible\n"); else printf("%d %d\n", A, B); } return 0;}
0 0
- Baby Ming and Weight lifting(BestCoder)
- BestCoder Baby Ming and Weight lifting 枚举
- Baby Ming and Weight lifting
- BestCoder Round #69-Baby Ming and Weight lifting(暴力)
- BestCoder Round #69 Baby Ming and Weight lifting
- HDU 5610: Baby Ming and Weight lifting
- HDOJ 5610 Baby Ming and Weight lifting
- HDOJ 5610-Baby Ming and Weight lifting
- hdu 5610 Baby Ming and Weight lifting
- HDOJ 5610 Baby Ming and Weight lifting
- HDU 5610 Baby Ming and Weight lifting
- hdoj-5610-Baby Ming and Weight lifting
- 【Best Coder】Baby Ming and Weight lifting(水)
- HDOJ 5610 Baby Ming and Weight lifting(枚举)
- hdoj Baby Ming and Weight lifting 5610 (暴力&转换)
- hdu5610 Baby Ming and Weight lifting(暴力)
- HDU 5610 Baby Ming and Weight lifting(贪心)
- hdu 5610 Baby Ming and Weight lifting(思维,逻辑)
- Swift 文档注释规范
- Git和Repo扫盲——如何取得Android源代码
- 【C++】在 Visual Studio 调试器中指定符号 (.pdb) 和源文件(转载自RSS翻译)
- 【技巧】对拍
- 开启CSDN博客第一天
- Baby Ming and Weight lifting(BestCoder)
- leetcode之valid sudoku
- C语言顺序访问文件6个方法
- nyoj456 邮票分你一半(01背包)
- UI组件之TimePiker
- PAT 1044. Shopping in Mars
- leetcode之Reverse Bits
- Baby Ming and phone number(BC)
- struts2拦截器