URAL 2035. Another Dress Rehearsal (乱搞)

33 篇文章 0 订阅

2035. Another Dress Rehearsal

Time limit: 0.5 second
Memory limit: 64 MB
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 +  B problem 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 ≤ AX and 0 ≤ BY. Help Kirill recover the tests!

Input

The only input line contains integers X, Y, and C separated with a space (0 ≤ X, Y, C ≤ 10 9).

Output

Find integers A and B such that 0 ≤ AX, 0 ≤ BY, and A +  B =  C.
If Kirill is wrong and there are no such integers, output “Impossible” (without quotation marks). Otherwise, output the integers A and B separated with a space. If there are several pairs satisfying the conditions, output any of them.

Samples

inputoutput
2 7 5
2 3
9 15 100
Impossible
Problem Author: Kirill Borozdin
Problem Source: Ural Regional School Programming Contest 2014




解析:0 ≤ AX, 0 ≤ BY, and A + B = C.




AC代码:

#include <bits/stdc++.h>
using namespace std;

int main(){
    __int64 a, b, k, ans1, ans2;
    while(~scanf("%I64d%I64d%I64d", &a, &b, &k)){
        if(a + b < k) puts("Impossible");
        else{
            if(a >= k){
                ans1 = k;
                ans2 = 0;
            }
            else{
                if(b >= k){
                    ans1 = 0;
                    ans2 = k;
                }
                else{
                    ans1 = a;
                    ans2 = k - a;
                }
            }
            printf("%I64d %I64d\n", ans1, ans2);
        }
    }
    return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值