URAL 2035 Another Dress Rehearsal 水题、易错
2016-07-30 23:10
344 查看
L - Another Dress Rehearsal
Time Limit:500MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u
Submit Status Practice URAL
2035
Description
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 ownA + 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 theAwesome
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 Bwere 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 C separated 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 integers A and Bseparated with a space. If there are several pairs satisfying the conditions,
output any of them.
Sample Input
Source
UESTC 2016 Summer Training #17 Div.2
URAL 2035
My Solution
虽然是水题但也WA了两发, 尴尬,
第一次WA, 是对于 x > c && y > c的情况没有处理好
第二次WA, 是由于 0 ≤ A ≤ X,
0 ≤ B ≤ Y
没有注意, 因为 A最大不能超过X, B 最大不能超过Y,
这个相对的就是如果 a = min(x, y) < c, 但是 max(x, y) > c, 这个时候可以 如果 y 小 则 b = y; a = c - b; 或者其实可以直接令大的为c, 然后小的为0 ☺☺
Thank you!
------from ProLights
Time Limit:500MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u
Submit Status Practice URAL
2035
Description
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 ownA + 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 theAwesome
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 Bwere 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 C separated 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 integers A and Bseparated with a space. If there are several pairs satisfying the conditions,
output any of them.
Sample Input
input | output |
---|---|
2 7 5 | 2 3 |
9 15 100 | Impossible |
UESTC 2016 Summer Training #17 Div.2
URAL 2035
My Solution
虽然是水题但也WA了两发, 尴尬,
第一次WA, 是对于 x > c && y > c的情况没有处理好
第二次WA, 是由于 0 ≤ A ≤ X,
0 ≤ B ≤ Y
没有注意, 因为 A最大不能超过X, B 最大不能超过Y,
这个相对的就是如果 a = min(x, y) < c, 但是 max(x, y) > c, 这个时候可以 如果 y 小 则 b = y; a = c - b; 或者其实可以直接令大的为c, 然后小的为0 ☺☺
#include <iostream> #include <cstdio> using namespace std; typedef long long LL; const int maxn = 1e6 + 8; int main() { #ifdef LOCAL freopen("a.txt", "r", stdin); //freopen("b.txt", "w", stdout); int T = 5; while(T--){ #endif // LOCAL //WA 5 6 0 int x, y, c, a, b; scanf("%d%d%d", &x, &y, &c); if(x + y < c) printf("Impossible"); else{ a = min(x, y); if(c >= a){ if(x > y){ b = y; a = c - b; } else{ a = x; b = c - a; } printf("%d %d", a, b); } else{ if(x > y){ b = 0; a = c; } else{ a = 0; b = c; } printf("%d %d", a, b); } } #ifdef LOCAL printf("\n"); } #endif // LOCAL return 0; }
Thank you!
------from ProLights
相关文章推荐
- URAL 1517. Freedom of choice(后缀数组:最长公共连续子串)
- URAL 1001. Reverse root
- 【C++复习】易错的小问题
- 中国人易错的30句口语
- 连接IBM MQ原因码报2035的错误解决办法
- java与SQL数据库桥接方式易错问题与设计核心
- HDU 2035-人见人爱A^B(乘方取模)
- 最长回文子串(ural1297)
- URAL 1088|Ilya Murometz|位运算|满二叉树的性质|LCA
- Ural 1081. Binary Lexicographic Sequence
- URAL1517-Freedom of Choice
- ural 1009 1012 1013 K-Based Numbers V1.0/2.0/3.0
- 匿名内部类的易错点. 1 2 3
- ural 1263 Elections
- URAL -1167 Bicolored Horses
- [URAL][1520][Empire Strikes Back][模拟退火]
- URAL - In the Army Now(归并排序求逆序数对)
- ural 1348. Goat in the Garden 2
- [BZOJ]1814 Ural 1519 Formula 1 插头DP
- ural 1208. Legendary Teams Contest