码迷,mamicode.com
首页 > 其他好文 > 详细

URAL 1409 Two Gangsters (开放思维)

时间:2015-03-04 12:57:40      阅读:122      评论:0      收藏:0      [点我收藏+]

标签:

Two Gangsters

Time limit: 1.0 second
Memory limit: 64 MB
Two gangsters Harry and Larry had a rest at countryside. They decided to spend some time shooting, so they put several beer cans (no more than 10) on a log. Harry started to shoot cans one after another from the leftmost to the right and Larry – from the rightmost to the left. At some moment it happened so that they shot one and the same can.
Harry got indignant and claimed that Larry owed him a considerable sum of money because Larry deprived him of shooting some more cans. Larry became furious and told Harry that he owed even greater sum of money to Larry because of the same reason. They started to argufy but nobody remembered how many cans there were at the very beginning. And no one of them was going to search cans which was shot. Anyway, each of them remembered exactly how many cans he shot.
Determine how many cans were not shot by Harry and how many cans were not shot by Larry.

Input

The only input line contains two integers — the number of cans shot by Harry and by Larry respectively.

Output

two integers — the number of cans that were not shot by Harry and the number of cans that were not shot by Larry, respectively.

Sample

input output
4 7
6 3




解析:关键是中间肯定会有一时刻,两者打到相同的瓶子。所以,一个人没打到的瓶子数,就是另一个人打到的瓶子数减一(两者同时打到的那个瓶子)。



AC代码:

#include <cstdio>

int main()
{
    int a, b;
    while(scanf("%d%d", &a, &b)!=EOF)
    {
        printf("%d %d\n", b - 1, a - 1);
    }
    return 0;
}



URAL 1409 Two Gangsters (开放思维)

标签:

原文地址:http://blog.csdn.net/u013446688/article/details/44058313

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!