zoukankan      html  css  js  c++  java
  • Simple Molecules(简单)

    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).

     1 #include <iostream>
     2 #include <cstdio>
     3 
     4 using namespace std;
     5 
     6 int get13(int a, int b, int c)
     7 {
     8     int i;
     9     for(i = 1; i <= a; ++i){
    10         if(c - i <= b && b - c + i == a - i && c - i >= 0){
    11             return i;
    12         }
    13     }
    14     for(i = 1; i <= a; ++i){
    15         if(b - i <= c && c - b + i == a - i && b - i >= 0){
    16             return i + 10e7;
    17         }
    18     }
    19     return -1;
    20 }
    21 
    22 int main()
    23 {
    24     int a, b, c;
    25     while(scanf("%d %d %d", &a, &b, &c) != EOF){
    26     int i = get13(a, b, c);
    27         if(i == -1) {
    28             puts("Impossible");
    29         }
    30         else if(i < 10e7){
    31             printf("%d %d %d
    ", a - i, b - a + i, i);
    32         }
    33         else{
    34             i -= 10e7;
    35             printf("%d %d %d
    ", i, c - a + i, a - i);
    36         }
    37     }
    38     return 0;
    39 }
  • 相关阅读:
    unity3d中获得物体的size
    Quartz中时间表达式的设置-----corn表达式
    .net web 开发平台- 表单设计器 一(web版)
    编写你自己的单点登录(SSO)服务
    2009年末最强梅麻呂3D动画游戏大作 汉化补丁
    程序猿加班到深夜,你经历过没?
    初步理解socket
    几种开源分词工具的比較
    ORM框架
    linux tar.gz zip 解压缩 压缩命令
  • 原文地址:https://www.cnblogs.com/cszlg/p/3329698.html
Copyright © 2011-2022 走看看