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 ...
随机推荐
- 【CSS3 入门教程系列】CSS3 Media Queries 实现响应式设计
在 CSS2 中,你可以为不同的媒介设备(如屏幕.打印机)指定专用的样式表,而现在借助 CSS3 的 Media Queries 特性,可以更为有效的实现这个功能.你可以为媒介类型添加某些条件,检测设 ...
- css初始化
Css初始化代码: *{padding:0px;margin:0px;} body{font-size:12px;font-family: "宋体",Arial Black;tex ...
- linux命令每日一练习 创建新文件 列出文件的时候带着行号
touch ××× nl ****
- Makefile 一点一滴(二)—— 输出文件到指定路径
先来看最简单的 makefile 文件: TestCpp : TestCpp.o g++ -o TestCpp TestCpp.o TestCpp.o : TestCpp.cpp g++ -c Tes ...
- centos7网络设置
1.设置虚拟机网络连接方式 2.启动改为从驱动启动 3.启动虚拟机,使用命令 ip addr 查看ip,发现网卡配置为 eno16777736 如果找不到网卡配置文件,请返回安装过程,查看是否正确选择 ...
- 如何查看前端部署的tracker代码
1.www.gov.cn 2.F12>Source>左侧选择static.gridsumdissector.com/js 3.点击代码下方区域的中括号,展开代码preety print{}
- Longest Substring Without Repeating Characters(Difficulty: Medium)
题目: Given a string, find the length of the longest substring without repeating characters. Examples: ...
- php 错误处理函数
eval() 把子符串当做php 代码执行 // 回调函数function a($b, $c) { echo $b; echo $c; } call_user_func_array('a', ar ...
- [SSH] SSH学习笔记 - 远程登录
1.SSH登陆/登出命令 $ ssh <hostname> #登入 $ exit #登出 known_hosts 每个用户都有自己的known_hosts文件,路径:(username)/ ...
- 模板volist自增变量