zoukankan      html  css  js  c++  java
  • CodeForces 344B Simple Molecules

    B. Simple Molecules
    time limit per test 
    1 second
    memory limit per test 
    256 megabytes
    input 
    standard input
    output 
    standard output

    Mad scientist Mike is busy carrying out experiments in chemistry. Today he will attempt to join three atoms into one molecule.

    A molecule consists of atoms, with some pairs of atoms connected by atomic bonds. Each atom has a valence number — the number of bonds the atom must form with other atoms. An atom can form one or multiple bonds with any other atom, but it cannot form a bond with itself. The number of bonds of an atom in the molecule must be equal to its valence number.

    Mike knows valence numbers of the three atoms. Find a molecule that can be built from these atoms according to the stated rules, or determine that it is impossible.

    Input

    The single line of the input contains three space-separated integers ab and c (1 ≤ a, b, c ≤ 106) — the valence numbers of the given atoms.

    Output

    If such a molecule can be built, print three space-separated integers — the number of bonds between the 1-st and the 2-nd, the 2-nd and the 3-rd, the 3-rd and the 1-st atoms, correspondingly. If there are multiple solutions, output any of them. If there is no solution, print "Impossible" (without the quotes).

    Sample test(s)
    input
    1 1 2
    output
    0 1 1
    input
    3 4 5
    output
    1 3 2
    input
    4 1 1
    output
    Impossible
    Note

    The first sample corresponds to the first figure. There are no bonds between atoms 1 and 2 in this case.

    The second sample corresponds to the second figure. There is one or more bonds between each pair of atoms.

    The third sample corresponds to the third figure. There is no solution, because an atom cannot form bonds with itself.

    The configuration in the fourth figure is impossible as each atom must have at least one atomic bond.

    题意:给出三个化学元素原子的化合价,问三个能够合理构成一个分子

    分析:暴力

    #pragma comment(linker, "/STACK:1024000000,1024000000")
    #include<cstdio>
    #include<string>
    #include<iostream>
    #include<cstring>
    #include<cmath>
    #include<stack>
    #include<queue>
    #include<vector>
    #include<map>
    #include<stdlib.h>
    #include<algorithm>
    #define LL __int64
    using namespace std;
    int main()
    {
        int a,b,c;
        int ab,ac,bc;
        int minn;
        bool flag=false;
        scanf("%d %d %d",&a,&b,&c);
        for(ab=0;ab<=min(a,b);ab++)
        {
            ac=a-ab;
            bc=b-ab;
            if(ac+bc==c)
            {
                flag=true;
                break;
            }
        }
        if(flag) printf("%d %d %d
    ",ab,bc,ac);
        else printf("Impossible
    ");
        return 0;
    }
    View Code
  • 相关阅读:
    HDU 4031 Attack(离线+线段树)(The 36th ACM/ICPC Asia Regional Chengdu Site —— Online Contest)
    BZOJ 1010 玩具装箱toy(四边形不等式优化DP)(HNOI 2008)
    分布式事务二阶提交DTS系统
    flume原理及代码实现
    Liferay JSP Tag Libraries介绍
    如何用maven tycho构建自己的Eclipse RCP应用
    如何合并两个git commit
    推荐一个好用的git图形化工具
    git gc干了啥
    如何把VS Code的Language Server Protocol整合到Eclipse中来
  • 原文地址:https://www.cnblogs.com/clliff/p/4721570.html
Copyright © 2011-2022 走看看