跳过正文
  1. Posts/

hdu 5610 ||BC #69 div2 1001 Baby Ming and Weight lifting

·1 分钟

http://acm.hdu.edu.cn/showproblem.php?pid=5610 题意:有重量为a,b两种铁圈每种无限多个…能能否组成一个重量为c且平衡杠铃(中间的杆的重量忽略不计) a,b,c都是整数。 思路:平衡的话。。就是两边重量一样。。那么c为奇数的时候显然不行。 由于有多组答案的时候输出铁圈数之和小的。。。那么我们枚举的话。应该把里面那层枚举的变量放置成重量较大的。。。。

 1/* ***********************************************
 2Author :111qqz
 3Created Time :2016年01月23日 星期六 18时56分38秒
 4File Name :code/bc/#69/1001.cpp
 5************************************************ */
 6
 7#include <cstdio>
 8#include <cstring>
 9#include <iostream>
10#include <algorithm>
11#include <vector>
12#include <queue>
13#include <set>
14#include <map>
15#include <string>
16#include <cmath>
17#include <cstdlib>
18#include <ctime>
19#define fst first
20#define sec second
21#define lson l,m,rt<<1
22#define rson m+1,r,rt<<1|1
23#define ms(a,x) memset(a,x,sizeof(a))
24typedef long long LL;
25#define pi pair < int ,int >
26#define MP make_pair
27
28using namespace std;
29const double eps = 1E-8;
30const int dx4[4]={1,0,0,-1};
31const int dy4[4]={0,-1,1,0};
32const int inf = 0x3f3f3f3f;
33int a,b,c;
34int main()
35{
36	#ifndef  ONLINE_JUDGE
37	freopen("code/in.txt","r",stdin);
38  #endif
39
40	int T;
41	cin>>T;
42	while (T--)
43	{
44	    bool isswap = false;
45	    scanf("%d %d %d",&a,&b,&c);
46	    if (c%2==1)
47	    {
48		puts("Impossible");
49		continue;
50	    }
51	    c/=2;
52	    if (a>b)
53	    {
54		swap(a,b);
55		isswap = true;
56	    }
57	    bool ok = false;
58	    for ( int i =  0 ; i*a<=c ;i++)
59	    {
60		for ( int j = 0 ; i*a+j*b <= c ; j++)
61		{
62		    if (i*a+j*b==c)
63		    {
64			ok = true;
65			if (isswap) cout<<j*2<<" "<<i*2<<endl;
66			    else cout<<i*2<<" "<<j*2<<endl;
67			break;
68		    }
69		}
70		if (ok) break;
71	    }
72	    if (!ok)
73	    {
74		puts("Impossible");
75	    }
76	}
77
78  #ifndef ONLINE_JUDGE
79  fclose(stdin);
80  #endif
81    return 0;
82}

相关文章

poj 1350 Cabric Number Problem

·1 分钟
http://poj.org/problem?id=1350 题意:6174问题。。。一个四位数。。四个数字重排。。。最大的减去最小的得到新的数字。最后一定能得到6174或者0.除非这个四位数的四个数字都一样。写出变化的过程。

codeforces 519 C. A and B and Team Training

·1 分钟
http://codeforces.com/problemset/problem/519/C 题意:两种组队方式,3人一组,1个大牛+2个蒟蒻或者1个蒟蒻+2个大牛。给定大牛和蒟蒻的个数。问最多能组多少队。 思路:线性规划。设两种队分别有x,y个即可。 突然发现这题以前做过。。。比当时的代码简单了一些。还不错。

有了这个列表,程序员不愁没练手的小项目了

·14 分钟
我经常看有人发帖问关于项目点子的事,也看到了很多回帖,我自己也回了一些常见的项目。不过我觉得只列出三两个是远远不够的,因此就收集并这个项目列表,大家要找简单的编程项目学习练手的话,可以收藏并扩散本文。这些项目并不是论文级别的,只是想抛砖引玉让大家能从中受些启发。

codeforces #334 div 2 C. Alternative Thinking

·2 分钟
题意:给定一个01串。要进行一次变换:选一段连续的非空的字串,将这段串的0和1反转(0变成1,1变成0) 然后问能得到的最长的0,1交替的序列的长度是多少(不一定连续)