cf B. Simple Molecules

http://codeforces.com/contest/344/problem/B

 1 #include <cstdio>
 2 #include <cstring>
 3 using namespace std;
 4 
 5 int main()
 6 {
 7     int a,b,c;
 8     int t1=0,t2=0,t3=0;
 9     while(scanf("%d%d%d",&a,&b,&c)!=EOF)
10     {
11         bool flag=false;
12         for(int i=0; i<=a; i++)
13         {
14             t1=i;
15             if(b-i>=0)
16             {
17                 t2=b-i;
18                 if(c-(b-i)==a-i)
19                 {
20                     flag=true;
21                     t3=c-(b-i);
22                     break;
23                 }
24             }
25         }
26         if(flag)
27         printf("%d %d %d
",t1,t2,t3);
28         else
29             printf("Impossible
");
30     }
31     return 0;
32 }
View Code
原文地址:https://www.cnblogs.com/fanminghui/p/3923004.html