博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
CodeForces - 344B Simple Molecules (模拟题)
阅读量:5295 次
发布时间:2019-06-14

本文共 2686 字,大约阅读时间需要 8 分钟。

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

 

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 
#include
#include
#include
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;}

转载于:https://www.cnblogs.com/cxchanpin/p/6821876.html

你可能感兴趣的文章
Delphi 的 TMS 控件安装方法
查看>>
常见跳转指令和机器码对应关系
查看>>
子查询
查看>>
P1262 间谍网络 (tarjan缩点 水过去)
查看>>
佳博80250打印机怎么看打印机IP
查看>>
[hdu4513]常规dp
查看>>
[hdu5521 Meeting]最短路
查看>>
HTTP 错误 500.22 - Internal Server Error
查看>>
ASIHTTPRequest框架官方文档
查看>>
qt,ui,QUiLoader
查看>>
494 - Kindergarten Counting Game
查看>>
Android 字体效果
查看>>
HDU 2103 Family Plan
查看>>
3.6.2投影峰谷查找
查看>>
小程序教程相关链接
查看>>
JFreeChart
查看>>
net3.5 无网络环境安装
查看>>
ARDUINO W5100 WebServer测试
查看>>
作业2
查看>>
mysql分页存储过程
查看>>