
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); } ; }
看题要认真。不把问题复杂化。