B. Simple Molecules
time limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard 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.
InputThe 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.
OutputIf 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).
Examplesinput1 1 2output0 1 1input3 4 5output1 3 2input4 1 1outputImpossibleNoteThe 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.
水题 求3个原子是否能构成一个分子使化学键和法。
总共的化学键为(a+b+c)/2个,则只要判断各原子间化学键是否成立即可。
附AC代码:
#include<bits/stdc++.h>
using namespace std; int main(){
int a,b,c;
cin>>a>>b>>c;
int t=(a+b+c)/;
int ans=;
int a1,a2,a3;
int flag=;
for(int i=;i<a;i++){
a1=i,a3=a-a1,a2=t-a;
if(a1+a2==b&&a2+a3==c){
flag=;
break;
}
}
if(flag==){
for(int i=;i<b;i++){
a1=i,a2=b-a1,a3=t-b;
if(a1+a3==a&&a2+a3==c){
flag=;
break;
}
}
}
if(flag==){
for(int i=;i<c;i++){
a3=i,a2=c-a3,a1=t-c;
if(a1+a3==a&&a2+a1==b){
flag=;
break;
}
}
}
if(flag&&a1>=&&a2>=&&a3>=){
cout<<a1<<" "<<a2<<" "<<a3<<endl;
}
else{
cout<<"Impossible"<<endl;
}
return ;
}
B. Simple Molecules的更多相关文章
- Simple Molecules(简单)
Simple Molecules time limit per test 1 second memory limit per test 256 megabytes input standard inp ...
- CodeForces - 344B Simple Molecules (模拟题)
CodeForces - 344B id=46665" style="color:blue; text-decoration:none">Simple Molecu ...
- codeforces Simple Molecules
link:http://codeforces.com/contest/344/problem/B 刚开始想复杂了.一开始就想当然地以为可以有多个点,其实,人家题目要求只有3个点啊! 然后题目就简单了. ...
- codeforces B. Simple Molecules 解题报告
题目链接:http://codeforces.com/problemset/problem/344/B 题目意思:这句话是解题的关键: The number of bonds of an atom i ...
- cf B. Simple Molecules
http://codeforces.com/contest/344/problem/B #include <cstdio> #include <cstring> using n ...
- Codeforces 344B Simple Molecules
#include<bits/stdc++.h> using namespace std; int main() { int a,b,c; scanf("%d%d%d", ...
- CodeForces Round 200 Div2
这次比赛出的题真是前所未有的水!只用了一小时零十分钟就过了前4道题,不过E题还是没有在比赛时做出来,今天上午我又把E题做了一遍,发现其实也很水.昨天晚上人品爆发,居然排到Rank 55,运气好的话没准 ...
- 我看的公开课系列--《TED:对无知的追求》 by stuart firestein
http://open.sina.com.cn/course/id_1047/ What scientists do is not just collect data and collect fact ...
- Codeforces Round #200 (Div. 1 + Div. 2)
A. Magnets 模拟. B. Simple Molecules 设12.13.23边的条数,列出三个等式,解即可. C. Rational Resistance 题目每次扩展的电阻之一是1Ω的, ...
随机推荐
- 手游产品经理初探(八)CasinoStar玩家离开原因分析
通过Delta DNA分析报告.综合我们的游戏进行思考,我总结了几条玩家流失的经验: 1.在有限的前60秒我们没有花足够的精力去吸引玩家.就是说我们要花大量的经历在玩家进入游戏的60秒的体验上(我的澳 ...
- gulp - sass 插件一直安装不好?
1.没有sass,只存在与scss 任务 gulp.task('scss', function() { return gulp.src(app.srcPath + '/sass/*.scss') .p ...
- Android手机输入法按键监听-dispatchKeyEvent
近期在项目开发中遇到一个关于手机输入键盘的坑.特来记录下. 应用场景: 项目中有一个界面是用viewpaper加三个fragment写的,当中viewpaper被我屏蔽了左右滑动,上面有三个点击按钮, ...
- LeetCode_DP_Word Break II
LeetCode_Word Break II 一.题目描写叙述: 二.解决思路: 题目要求我们要在原字符串中加空格,使得隔开的每一个词都是词典中的词. 所以我们大能够按顺序扫描每一个字符.可是然后当碰 ...
- Qt Quick之StackView具体解释(1)
Qt Quick中有个StackView.我在<Qt Quick核心编程>一书中没有讲到.近期有人问起,趁机学习了一下,把它的基本使用方法记录下来. 我准备分两次来讲.第一次讲主要的使用方 ...
- RecyclerViewDemo
https://github.com/eltld/RecyclerViewDemo
- 简单的dp hdu 数塔(水题)
数塔 Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submiss ...
- 项目Beta冲刺(团队7/7)
项目Beta冲刺(团队7/7) 团队名称: 云打印 作业要求: 项目Beta冲刺(团队) 作业目标: 完成项目Beta版本 团队队员 队员学号 队员姓名 个人博客地址 备注 221600412 陈宇 ...
- POJ 2892 Tunnel Warfare(树状数组+二分)
题目链接 二分求上界和下界,树状数组.注意特殊情况. #include <cstring> #include <cstdio> #include <string> ...
- Hihocoder #1527 : 快速乘法 DP
时间限制:20000ms 单点时限:1000ms 内存限制:256MB 描述 在写代码时,我们经常要用到类似 x × a 这样的语句( a 是常数).众所周知,计算机进行乘法运算是非常慢的,所以我们需 ...