If you have a long history of participating in programming contests, you should know that the dress rehearsal is the most important part of a contest. There are permanent participants who attend contests not because of results or promotional gifts from sponsors but specially to solve a new quiz prepared by Alexander Ipatov.
At Ural programming contests, dress rehearsals are made into a cult, and their problems are often prepared more thoroughly than the problems of main contests. For example, have you ever seen rejudging at a dress rehearsals? Now you understand it.
But however difficult problems the organizers prepare for a dress rehearsal, there is always the good old A + B. Do you think it is simply copied from one contest to another? Of course not! Any self-respecting organizing committee considers it its duty to prepare its own A + Bproblem with negative numbers and int64.
A contest is approaching, and Kirill has prepared a superdifficult set of tests and answers to them. Unfortunately, he forgot to backup the tests, and, after an update of the Hardsoft Doors operating system, all the test were lost. It will take some time before Kirill invents the Awesome Backup System, but that’s a different story.
Now Kirill has to recover the lost tests as soon as possible. He has answers to the tests, and he remembers that the summands A and B were integers such that 0 ≤ A ≤ X and 0 ≤ B ≤ Y. Help Kirill recover the tests!
Input
The only input line contains integers X, Y, and Cseparated with a space (0 ≤ X, Y, C ≤ 10 9).
Output
Find integers A and B such that 0 ≤ A ≤ X, 0 ≤B ≤ Y, and A + B = C.
If Kirill is wrong and there are no such integers, output “Impossible” (without quotation marks). Otherwise, output the integersA and B separated with a space. If there are several pairs satisfying the conditions, output any of them.
Example
input | output |
---|---|
2 7 5 | 2 3 |
9 15 100 | Impossible |
AC代码(交换!!!不知道大小又是这个坑然后如果开始的时候交换的话那么输出的时候也要交换然后就是分情况讨论一下就好了)
Select Code
#include <iostream>
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
int main()
{
int x, y, c, t, f = 0;
scanf("%d %d %d",&x,&y,&c);
if(c>x+y)
printf("Impossible\n");
else
{
if(x>y)
{
t = x, x = y, y = t;
f = 1;
}
if(c<=x)
{
if(f==0)
{
printf("%d %d\n",0, c);
}
else
printf("%d %d\n",c, 0);
}
else
if(f==0)
printf("%d %d\n", x, c-x);
else
printf("%d %d\n",c-x, x);
}
return 0;
}