hdu 5610 Baby Ming and Weight lifting
Baby Ming prepare to use this two kinds of barbell disks to make up a new one weighted C(the barbell must be balanced), he want to know how to do it.

For each test case:
There are three positive integer a,b, and C.
1≤T≤1000,0<a,b,C≤1000,a≠b
Otherwise, print two numbers to indicating the numbers of a and b barbell disks are needed. (If there are more than one answer, print the answer with minimum a+b)
1 2 6
1 4 5
Impossible
直接暴力枚举
AC代码:
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<bitset>
#include<map>
#include<vector>
#include<stdlib.h>
using namespace std;
#define ll long long
#define eps 1e-10
#define MOD 1000000007
#define N 1000000
#define inf 1e12
int a,b,c;
int main()
{
int t;
scanf("%d",&t);
while(t--){
scanf("%d%d%d",&a,&b,&c);
if(c&){
printf("Impossible\n");
continue;
}
int half = c/; int ans = ;
int ans1,ans2;
for(int i=;i<=;i++){
for(int j=;j<=;j++){
int cnt = i*a + j*b;
if(cnt==half){
if(ans>i+j){
ans=min(ans,i+j);
ans1=i,ans2=j;
}
}
}
}
if(ans==){
printf("Impossible\n");
continue;
}
printf("%d %d\n",ans1*,ans2*);
}
return ;
}
hdu 5610 Baby Ming and Weight lifting的更多相关文章
- BestCoder Round #69 (div.2) Baby Ming and Weight lifting(hdu 5610)
Baby Ming and Weight lifting Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K ( ...
- hdu 5612 Baby Ming and Matrix games
Baby Ming and Matrix games 题意: 给一个矩形,两个0~9的数字之间隔一个数学运算符(‘+’,’-‘,’*’,’/’),其中’/’表示分数除,再给一个目标的值,问是否存在从一 ...
- hdu 5612 Baby Ming and Matrix games(dfs暴力)
Problem Description These few days, Baby Ming is addicted to playing a matrix game. Given a n∗m matr ...
- hdu 5611 Baby Ming and phone number(模拟)
Problem Description Baby Ming collected lots of cell phone numbers, and he wants to sell them for mo ...
- HDU 5612 Baby Ming and Matrix games(DFS)
题目链接 题解:题意为给出一个N*M的矩阵,然后(i∗2,j∗2) (i,j=0,1,2...)的点处是数字,两个数字之间是符号,其他位置是‘#’号. 但不知道是理解的问题还是题目描述的问题,数据中还 ...
- HDU 5613 Baby Ming and Binary image
因为第一行和最后一行都是0,我们只需枚举最左边或最右边一列的01情况,即可得到整张表 然后再检验表是否符合要求 #include<cstdio> #include<cstring&g ...
- HDU 5611 Baby Ming and phone number
#include<cstdio> #include<cstring> #include<vector> #include<cmath> #include ...
- HDU 5614 Baby Ming and Matrix tree 树链剖分
题意: 给出一棵树,每个顶点上有个\(2 \times 2\)的矩阵,矩阵有两种操作: 顺时针旋转90°,花费是2 将一种矩阵替换为另一种矩阵,花费是10 树上有一种操作,将一条路经上的所有矩阵都变为 ...
- Codeforces Round #326 (Div. 2) B. Pasha and Phone C. Duff and Weight Lifting
B. Pasha and PhonePasha has recently bought a new phone jPager and started adding his friends' phone ...
随机推荐
- pyqt QTreeWidget例子学习
# -*- coding: utf-8 -*- # python:2.x __author__ = 'Administrator' from PyQt4.QtGui import * from Py ...
- 如何实现 iOS 自定义状态栏
给大家介绍如何实现 iOS 自定义状态栏 Sample Code: 01 UIWindow * statusWindow = [[UIWindow alloc] initWithFrame:[UIAp ...
- 文章转载至CSDN社区罗升阳的安卓之旅,原文地址:
文章转载至CSDN社区罗升阳的安卓之旅,原文地址:http://blog.csdn.net/luoshengyang/article/details/6720261 前面我们在分析Activity启动 ...
- zabbix-web界面图形中文乱码解决方法
1.搜索windows-server X86-64机器上C:/windows/fonts的simkai.tts文件,windows7下有时候不行. 2.把它拷贝到zabbix的web端的fonts目录 ...
- Android中Binder的基础知识点
Android Binder基础知识点 一 传统IPC和Binder机制的比较 传统IPC: 1)收方无法获得对方进程可靠的UID/PID,从而无法鉴别对方身份. 2)接入点开放,无法建立私有通道. ...
- mysql的join
SELECT * FROM a LEFT JOIN b ON a.aID = b.bID; a为主,a的数据全显示,连不上b的对应字段为空 SELECT * FROM a RIGHT JOIN ...
- jBPM4.4与SSH2整合
整合jBPM的目的就是能够通过注入的方式得到ProcessEngine实例,因为ProcessEngine是jbpm 的核心. 整合步骤: 1.新建web程,搭建好SSH2环境 2.导入jbpm相关的 ...
- EC读书笔记系列之1:条款1、条款2、条款3
条款1:视C++为一个语言联邦 记住: ★C++高效编程守则视状况而变化,这取决于你使用C++的哪一部分 C: Object-oriented c++: Template c++: STL 条款2:尽 ...
- SQL语句 计算某段时间工作日的天数(除了周六日)
--只是加了固定日期,可以根据需求给成变量形式(BY 少年工藤) -思路:根据日期区间循环判断每一天是周日(1).周六(7)不变,其他加1 1 DECLARE @DAY DATE,@COUNT INT ...
- C#读写word
操作word之前需要在COM引入Microsoft Office 12.0 Object Library(文件库可能不一样) 然后添加using Microsoft.Office.Interop.Wo ...