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 最坏 ...
随机推荐
- LA 4123 (计数 递推) Glenbow Museum
题意: 这种所有边都是垂直或水平的多边形,可以用一个字符串来表示,一个270°的内角记作O,一个90°的内角记作R. 如果多边形内存在一个点,能看到该多边形所有的点,则这个多边形对应的序列是合法的.这 ...
- Codeforces Round #270
A 题意:给出一个数n,求满足a+b=n,且a+b均为合数的a,b 方法一:可以直接枚举i,n-i,判断a,n-i是否为合数 #include<iostream> #include< ...
- asp.net的decimal保留两位小数
C#的decimal保留两位小数 方法一: decimal d = 46.28111; string dStr = Math.Round( d,2 ).ToString(); 结果:dStr = 46 ...
- [转] Jquery滚动加载
原文地址:http://hi.baidu.com/vipxiaofan/item/9eb927b795671f77254b0985 另外一个asp.net的例子:http://blog.csdn.ne ...
- cocos2dx场景切换中init、onEnter、onEnterTransitionDidFinish的调用顺序
这些方法调用的先后顺序如下(使用 replaceScene 方法): 1. 第2个场景的 scene 方法 2. 第2个场景的 init 方法 3. 第2个场景的 onEnter 方法 4. 转场 5 ...
- Scrum&Kanban在移动开发团队的实践 (一)
现在大多数团队都在谈敏捷开发,似乎觉得敏捷是软件开发的银弹.只需要实践下一些敏捷开发的模式就能如何如何,其实我觉得不论是敏捷开发还是传统的瀑布流开发都是有他们的市场的,取决于团队人员构成,取决你的产品 ...
- Linux下通过ioctl系统调用来获取和设置网络信息
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h&g ...
- mysql SQL_MODE设置
1.1. SQL_MODE设置 在生产环境中强烈建议将这个值设置为严格模式,这样有些问题可以在数据库的设计和开发阶段就能实现,而如果在生产环境下运行数据库后发现这类问题,那么修改的代价将变得十分巨 ...
- CXF之七 传输文件
CXF的文件传输通过MTOM实现.MTOM(SOAP Message Transmission Optimization Mechanism)SOAP消息传输优化机制,可以在SOAP消息中发送二进制数 ...
- 擦亮自己的眼睛去看SQLServer之简单Insert(转)
摘要:本来是打算先写SQLServer历史的,不过感觉写那部分内容比较难还需要多查些资料.于是调整了下顺序写下简单的Insert语句. 不过感觉写那部分内容比较难还需要多查些资料.于是调整了下顺序写下 ...