CodeForces 344B
2016-01-18 15:39
330 查看
Time Limit:1000MS Memory Limit:262144KB 64bit IO Format:%I64d
& %I64u
Description#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<math.h>
using namespace std;
int main()
{
int a,b,c,i,ta,tb,tc,t=0;;
cin>>a>>b>>c;
for(i=0;i<=a;i++)
{
tb=i;tc=a-i;
if(tb>c)
continue;
ta=c-tb;
if(b==ta+tc)
{
printf("%d %d %d\n",tc,ta,tb);
t=1;
break;
}
}
if(t==0)
{
printf("Impossible\n");
}
return 0;
}
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
a, b 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
Output
Input
Output
Input
Output
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.
& %I64u
Description#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<math.h>
using namespace std;
int main()
{
int a,b,c,i,ta,tb,tc,t=0;;
cin>>a>>b>>c;
for(i=0;i<=a;i++)
{
tb=i;tc=a-i;
if(tb>c)
continue;
ta=c-tb;
if(b==ta+tc)
{
printf("%d %d %d\n",tc,ta,tb);
t=1;
break;
}
}
if(t==0)
{
printf("Impossible\n");
}
return 0;
}
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
a, b 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.
相关文章推荐
- linux 怎么样复制文件夹内所有文件到另一个文件夹?
- [cuda] host thread
- 微信红包签名算法 C#代码实现
- c++线程同步和通信
- SimpleDateFormat使用详解 <转>
- 模块安装
- Android 自定义View画‘√’
- iOS9 提示框的使用
- CodeForces 343A
- JAVA加密解密之DH(Diffie-Hellman)算法
- Objective-C语法-字符串NSString和可变字符串NSMutableString
- GTP协议的分析 http://blog.csdn.net/stephen_yin/article/details/6951258
- 115个Java面试题和答案——终极列表(上)
- 217,FMDB数据库操作
- Hdu 1166 敌兵布阵 -- 树状数组
- <蜡烛图精解Candlestick Charting Explained>-- 笔记1
- setFilters使用方法
- Java-如何去掉JFrame上的最大化最小化和关闭按钮(转)
- 根据图片尺寸生成缩略图.
- boost学习2.7:处理时间