CodeForces - 344B

Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u

id=46665" class="login ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" style="display:inline-block; position:relative; padding:0px; margin-right:0.1em; vertical-align:middle; overflow:visible; text-decoration:none; font-family:Verdana,Arial,sans-serif; border:1px solid rgb(211,211,211); color:blue; font-size:12px!important">Submit Status

Description

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 Input

Input
1 1 2
Output
0 1 1
Input
3 4 5
Output
1 3 2
Input
4 1 1
Output
Impossible

Hint

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.

如果A、B、C代表原子的化合价

如果x、y、z代表原子之间的化学键

首先x+y+z一定为偶数,否则不可能有解。

那么能够列出一个三元一次的方程组。由3个方程组成,能够求出唯一解。

推断有解的唯一限制条件是:不能出现负数。



#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;
int main() {
//freopen("D://imput.txt","r",stdin);
int a, b, c, x, y, z, temp1, temp2;
while(cin >> a >> b >> c) {
temp1 = a + b + c;
temp2 = b - a + c ;
if(temp1 & 1) {
cout << "Impossible" << endl;
continue;
}
if(temp2 & 1) {
cout << "Impossible" << endl;
continue;
}
x = a - (z = c - (y = temp2 / 2));
if(x < 0 || y < 0 || z < 0) {
cout << "Impossible" << endl;
continue;
}
cout << x << " " << y << " " << z << endl;
}
return 0;
}

CodeForces - 344B Simple Molecules (模拟题)的更多相关文章

  1. Codeforces 344B Simple Molecules

    #include<bits/stdc++.h> using namespace std; int main() { int a,b,c; scanf("%d%d%d", ...

  2. Codeforces 767B. The Queue 模拟题

    B. The Queue time limit per test:1 second memory limit per test:256 megabytes input:standard input o ...

  3. Codeforces 691C. Exponential notation 模拟题

    C. Exponential notation time limit per test: 2 seconds memory limit per test:256 megabytes input: st ...

  4. codeforces B. Simple Molecules 解题报告

    题目链接:http://codeforces.com/problemset/problem/344/B 题目意思:这句话是解题的关键: The number of bonds of an atom i ...

  5. CodeForces - 344D Alternating Current (模拟题)

    id=46667" style="color:blue; text-decoration:none">CodeForces - 344D id=46667" ...

  6. CodeForces - 344E Read Time (模拟题 + 二分法)

    E. Read Time time limit per test 1 second memory limit per test 256 megabytes input standard input o ...

  7. CodeForces - 665D Simple Subset 想法题

    //题意:给你n个数(可能有重复),问你最多可以取出多少个数使得任意两个数之和为质数.//题解:以为是个C(2,n)复杂度,结果手摸几组,发现从奇偶性考虑,只有两种情况:有1,可以取出所有的1,并可以 ...

  8. CodeForces 681C Heap Operations (模拟题,优先队列)

    题意:给定 n 个按顺序的命令,但是可能有的命令不全,让你补全所有的命令,并且要求让总数最少. 析:没什么好说的,直接用优先队列模拟就行,insert,直接放入就行了,removeMin,就得判断一下 ...

  9. Codeforces Beta Round #7 B. Memory Manager 模拟题

    B. Memory Manager 题目连接: http://www.codeforces.com/contest/7/problem/B Description There is little ti ...

随机推荐

  1. 软工实践 - 第九次作业 Alpha 冲刺 (1 / 10)

    队名:起床一起肝活队 组长博客:https://www.cnblogs.com/dawnduck/p/9949350.html 作业博客:(班级博客本次作业的链接) 组员情况 组员1(队长):白晨曦 ...

  2. jquery版右下角弹窗效果

    <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...

  3. [ZJOI2014][bzoj3527]力 [FFT]

    题面 传送门 思路 把要求的公式列出来: $E_i=\frac{F_i}{q_i}=\sum_{j=1}^i\frac{q_j}{\left(i-j\right)^2}-\sum_{j=i+1}^n\ ...

  4. Python之面向对象:方法

    一.类的三种方法 1.实例方法 def func(self): 由对象调用:至少一个self参数:执行普通方法时,自动将调用该方法的对象赋值给self: 只能通过实例调用   2.静态方法 @stat ...

  5. JAVA 字节流和字符流度读写的区别

    java处理文件的类里面,stream结尾都是采用字节流,reader和writer结尾都是采用字符流.两者的区别就是读写的时候一个是按字节读写,一个是按字符. 字符流的底层就是字节流.而字符流主要是 ...

  6. git常用命令符

    全局配置 $ git config --global user.name "姓名" 告诉git你是谁 $ git config --global user.email " ...

  7. LOJ#2083. 「NOI2016」优秀的拆分

    $n \leq 30000$的字符串,问其所有子串的所有AABB形式的拆分有多少种.$t \leq 10$组询问. $n^3$过80,$n^2$过95,鬼去写正解.. $n^2$:先枚举一次算每个位置 ...

  8. CentOS 基本操作

    1.Vi 基本操作 1) 进入vi  在系统提示符号输入vi及文件名称后,就进入vi全屏幕编辑画面:  $ vi myfile  进入vi之后,是处于「命令行模式(command mode)」,您要切 ...

  9. hdu 2243 考研路茫茫——单词情结 AC自动机 矩阵幂次求和

    题目链接 题意 给定\(N\)个词根,每个长度不超过\(5\). 问长度不超过\(L(L\lt 2^{31})\),只由小写字母组成的,至少包含一个词根的单词,一共可能有多少个? 思路 状态(AC自动 ...

  10. 老郭带你学数据结构(C语言系列)2-线性表之动态顺序表

    一.基本概念: 线性表:由n个类型相同的数据元素组成的有限序列,记为(a1,a2,--an). 线性表的特征:其中的元素存在这序偶关系,元素之间存在着严格的次序关系. 顺序存储表:线性表中的元素依次存 ...