codeforces Simple Molecules
link:http://codeforces.com/contest/344/problem/B
刚开始想复杂了。一开始就想当然地以为可以有多个点,其实,人家题目要求只有3个点啊!
然后题目就简单了。

A、B、C代表原子的化合价
x、y、z代表原子之间的化学键
首先x+y+z一定为偶数,否则不可能有解。
那么可以列出一个三元一次的方程组,由3个方程组成,可以求出唯一解。
判断有解的唯一限制条件是:不能出现负数。
#include <cstdlib>
#include <cstdio>
#include <cmath>
int main(void)
{
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
#endif // ONLINE_JUDGE
int a, b, c;
int x, y, z;
while (~scanf("%d%d%d", &a, &b, &c))
{
int sum = a + b + c;
)
{
printf("Impossible\n"); continue;
}
int tmp = b - a + c;
)
{
printf("Impossible\n");
continue;
}
y = tmp >> ;
z = c - y;
x = a - z;
|| y < || z < )
{
printf("Impossible\n");
continue;
}
printf("%d %d %d\n", x, y, z);
}
;
}
看题要认真。不把问题复杂化。
codeforces Simple Molecules的更多相关文章
- CodeForces - 344B Simple Molecules (模拟题)
CodeForces - 344B id=46665" style="color:blue; text-decoration:none">Simple Molecu ...
- Simple Molecules(简单)
Simple Molecules time limit per test 1 second memory limit per test 256 megabytes input standard inp ...
- codeforces B. Simple Molecules 解题报告
题目链接:http://codeforces.com/problemset/problem/344/B 题目意思:这句话是解题的关键: The number of bonds of an atom i ...
- Codeforces 344B Simple Molecules
#include<bits/stdc++.h> using namespace std; int main() { int a,b,c; scanf("%d%d%d", ...
- cf B. Simple Molecules
http://codeforces.com/contest/344/problem/B #include <cstdio> #include <cstring> using n ...
- B. Simple Molecules
time limit per test 1 second memory limit per test 256 megabytes input standard input output standar ...
- CodeForces Round 200 Div2
这次比赛出的题真是前所未有的水!只用了一小时零十分钟就过了前4道题,不过E题还是没有在比赛时做出来,今天上午我又把E题做了一遍,发现其实也很水.昨天晚上人品爆发,居然排到Rank 55,运气好的话没准 ...
- Codeforces Round #200 (Div. 1 + Div. 2)
A. Magnets 模拟. B. Simple Molecules 设12.13.23边的条数,列出三个等式,解即可. C. Rational Resistance 题目每次扩展的电阻之一是1Ω的, ...
- 我看的公开课系列--《TED:对无知的追求》 by stuart firestein
http://open.sina.com.cn/course/id_1047/ What scientists do is not just collect data and collect fact ...
随机推荐
- hudson slave搭建
Hudson Slave搭建 使用Hudson搭建分布式的构建环境非常方便,客户端也不需要太多的操作,只要能执行java命令就行. hudson默认采用master方式进行安装,master作为 ...
- CALayer笔记
1.Core Animation是跨平台的,支持IOS和Mac OS X环境 2.核心动画操作的对象不是UIView而是CALayer,CALayer是核心动画的基础, 可以做圆角.阴影.边框等效果 ...
- ie7 用 clearfix 清除浮动时遇到的问题
<!doctype html> <html> <head> <style> .fr{float:right;display:inline} li{bor ...
- 深入理解unslider.js源码
最近用到了一个挺好用的幻灯片插件,叫做unslider.js,就想看看怎么实现幻灯片功能,就看看源码,顺便自己也学习学习.看完之后收获很多,这里和大家分享一下. unslider.js 源码和使用教程 ...
- img标签中的alt属性在IE6/7/8中的兼容问题
W3C HTML 4.01 规范规定,alt 属性指定了在 User Agents 不能显示图片.表单和 applets 的时候显示的替换文字.alt 属性在 IE6 IE7 IE8(Q) 下具有双重 ...
- hdu4067
//Accepted 1812 KB 514 ms /* source:hdu4067 time :20150816 by :songt */ /*题解:网络流 首先我们贪心建图:对于u到v的一条边, ...
- C语言程序设计第十一次作业
同学们,一晃一个学期就过去了,第一节课时,我曾做过一个调查,没有一个同学在中学阶段接触过程序设计,也就是说,那时,大家都是零基础,或许只是听说过"C语言"这个词,但其他便一无所知了 ...
- fushioncharts 使用教程要点---使用JSON数据方式
1.建立图表步骤: A.下载fushionChart,引入FusionCharts.js和FusionChartsExportComponent.js文件 B.建立图表对象 var chart1 = ...
- LeetCode 7 -- String to Integer (atoi)
Implement atoi to convert a string to an integer. 转换很简单,唯一的难点在于需要开率各种输入情况,例如空字符串,含有空格,字母等等. 另外需在写的时候 ...
- 本地测试AJAX请求
要在本地测试AJAX,首先是环境的搭建,因为XHR对象的open方法中参数url是指文件在服务器上的文件.下面以WampServer为例. 1. 下载wamp的安装包,下载地址为:http://221 ...