CF#200 div2 B Simple Molecules(Brute force)

来源:互联网 发布:java订单管理系统 编辑:程序博客网 时间:2024/06/06 09:40

地址

http://codeforces.com/problemset/problem/344/B

题意

给A,B,C三个点的度,(1a,b,c106) ,求三个点是否能连成一个整体,并输出方案。第一个数代表AB之间的边数,第二个数代表BC之间的,第三个数代表CA之间的。

总结

居然没有想到暴力,居然没有想到暴力,居然没有想到暴力。。。

代码

#pragma comment(linker, "/STACK:1677721600")#include <map>#include <set>#include <cmath>#include <queue>#include <stack>#include <vector>#include <cstdio>#include <cstdlib>#include <cstring>#include <climits>#include <cassert>#include <iostream>#include <algorithm>#define pb push_back#define mp make_pair#define LL long long#define lson lo,mi,rt<<1#define rson mi+1,hi,rt<<1|1#define Min(a,b) ((a)<(b)?(a):(b))#define Max(a,b) ((a)>(b)?(a):(b))#define mem(a,b) memset(a,b,sizeof(a))#define FIN freopen("in.txt", "r", stdin)#define FOUT freopen("out.txt", "w", stdout)#define rep(i,a,b) for(int i=(a); i<=(b); i++)#define dec(i,a,b) for(int i=(a); i>=(b); i--)using namespace std;const int mod = 1e9 + 7;const double eps = 1e-8;const double ee = exp(1.0);const int inf = 0x3f3f3f3f;const int maxn = 1e5 + 10;const double pi = acos(-1.0);int readT(){    char c;    int ret = 0,flg = 0;    while(c = getchar(), (c < '0' || c > '9') && c != '-');    if(c == '-') flg = 1; else ret = c ^ 48;    while( c = getchar(), c >= '0' && c <= '9') ret = ret * 10 + (c ^ 48);    return flg ? - ret : ret;}LL readTL(){    char c;    int flg = 0;    LL ret = 0;    while(c = getchar(), (c < '0' || c > '9') && c != '-');    if(c == '-') flg = 1; else ret = c ^ 48;    while( c = getchar(), c >= '0' && c <= '9') ret = ret * 10 + (c ^ 48);    return flg ? - ret : ret;}int main(){    #ifdef LOCAL    FIN;    #endif // LOCAL    int a = readT();    int b = readT();    int c = readT();    int ans1 = -1, ans2, ans3;    for (int i = 0; i <= Min(a, b); i++)    {        int tac = Max(a - i, 0);        int tbc = Max(b - i, 0);        if ((tac || tbc) && (tac + tbc) == c)        {            ans1 = i, ans2 = b - i, ans3 = a - i;            break;        }    }    if (ans1 == -1)        puts("Impossible");    else    {        cout << ans1 << " " << ans2 << " " << ans3 << endl;    }    return 0;}
0 0
原创粉丝点击