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 (Java/Others)
Total Submission(s): 681 Accepted Submission(s): 280
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)
题意:有A B两种杠铃盘,杠铃杆的重量忽略,这两种盘都有无限个,现在让你用这两种盘来制作新的杠铃C问需要A B多少个(n,m) 如果有多种方案,取n+m最少的
注意:杠铃的两端必须重量相等,
分析1、c的值必须为偶数2、制作c必须使A的个数和B的个数都为偶数(可以为0)
题解:因为题目数据不大 所以直接枚举所有情况
#include<stdio.h>
#include<string.h>
#include<string>
#include<math.h>
#include<algorithm>
#define LL long long
#define PI atan(1.0)*4
#define DD doublea
#define MAX 10100
#define mod 10007
using namespace std;
int ans[MAX];
int main()
{
int n,m,j,i,t,k;
int a,b,c,Min1,x,y;
scanf("%d",&t);
while(t--)
{
scanf("%d%d%d",&a,&b,&c);
n=m=0;
if(c&1)
{
printf("Impossible\n");
continue;
}
Min1=1000000;x=y=0;
for(i=0;i<=1000;i+=2)
{
for(j=0;j<=1000;j+=2)
{
if(c==i*a+j*b)
{
if(i+j<Min1)
{
x=i;y=j;
Min1=i+j;
}
}
}
}
if(Min1>10000) printf("Impossible\n");
else printf("%d %d\n",x,y);
}
return 0;
}
BestCoder Round #69 (div.2) Baby Ming and Weight lifting(hdu 5610)的更多相关文章
- 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 5610 Baby Ming and Weight lifting
Problem Description Baby Ming is fond of weight lifting. He has a barbell pole(the weight of which c ...
- BestCoder Round #69 (div.2)(hdu5611)
Baby Ming and phone number Time Limit: 3000/1500 MS (Java/Others) Memory Limit: 65536/65536 K (Ja ...
- Codeforces Round #346 (Div. 2)---E. New Reform--- 并查集(或连通图)
Codeforces Round #346 (Div. 2)---E. New Reform E. New Reform time limit per test 1 second memory lim ...
- BestCoder Round 69 Div 2 1001&& 1002 || HDU 5610 && 5611
题目:http://acm.hdu.edu.cn/showproblem.php?pid=5610 如果杠铃总质量是奇数直接impossible 接着就考验耐心和仔细周全的考虑了.在WA了三次后终于发 ...
- Codeforces Round #384 (Div. 2) B. Chloe and the sequence(规律题)
传送门 Description Chloe, the same as Vladik, is a competitive programmer. She didn't have any problems ...
- Codeforces Round #356 (Div. 2)B. Bear and Finding Criminals(水题)
B. Bear and Finding Criminals time limit per test 2 seconds memory limit per test 256 megabytes inpu ...
- Codeforces Round #356 (Div. 2)A. Bear and Five Cards(简单模拟)
A. Bear and Five Cards time limit per test 2 seconds memory limit per test 256 megabytes input stand ...
- Codeforces Round #248 (Div. 2) C. Ryouko's Memory Note (vector 替换)
题目链接 题意:给m个数字, 这些数字都不大于 n, sum的值为相邻两个数字 差的绝对值.求这n个数字里把一个数字 用 其中另一个数字代替以后, 最小的sum值. 分析:刚开始以为两个for 最坏 ...
随机推荐
- 8天学通MongoDB——第六天 分片技术
在mongodb里面存在另一种集群,就是分片技术,跟sql server的表分区类似,我们知道当数据量达到T级别的时候,我们的磁盘,内存 就吃不消了,针对这样的场景我们该如何应对. 一:分片 mong ...
- km算法的个人理解
首先相对于上个blog讲的匈牙利算法用于解决无权二分图的最佳匹配,km算法则是在匈牙利算法基础上更进一层的,每条边增加了权值后,真的开始看时有些无厘头,觉得没有什么好方法,但两位牛人Kuhn-Munk ...
- main cannot be resolved or is not a field
今天在做XML解析的时候,总是给我报 XML Parsing Error: XML or text declaration not at start of entity 的错误,后来查了下讲大概意思是 ...
- js 写成类的形式 js 静态变量 js方法 属性 json类
function ClassStudentList() { //[{"Cid":"0d","Students":[{"Sid&qu ...
- Material Design 设计--阴影的重要性
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_cont ...
- 最简单的视音频播放示例8:DirectSound播放PCM
本文记录DirectSound播放音频的技术.DirectSound是Windows下最常见的音频播放技术.目前大部分的音频播放应用都是通过DirectSound来播放的.本文记录一个使用Direct ...
- IOS的XML文件解析,利用了NSData和NSFileHandle
如果需要了解关于文档对象模型和XML的介绍,参看 http://www.cnblogs.com/xinchrome/p/4890723.html 读取XML 上代码: NSFileHandle *fi ...
- 常用的PL/SQL开发原则
(1)广泛使用绑定变量,特别是批量绑定,因为这可以有效的避免sql的硬解析和PL/SQL引擎和SQL引擎的上下文切换!(2)广泛使用UROWID来处理DML语句(UROWID是ROWID扩展,ORAC ...
- iOS开发:AFNetworking、MKNetworkKit和ASIHTTPRequest比较
转:http://www.xue5.com/Mobile/iOS/747036.html 之前一直在使用ASIHTTPRequest作为网络库,但是由于其停止更新,iOS7上可能出现更多的问题,于是决 ...
- [Everyday Mathematics]20150108
设 $f$ 在 $(a,b)$ 上 $n+1$ 次可导, 且 $$\bex \ln\frac{f(b)+f'(b)+\cdots+f^{(n)}(b)}{f(a)+f'(a)+\cdots+f^{(n ...