URAL 1409 Bishops 思维问题

哈里和拉里在乡村进行射击比赛,分别从两端开始射击,最终发现有相同目标被击中。他们争论谁应该为对方失去的机会支付赔偿金。此篇博客详细解析如何计算未被哈里和拉里各自射击的目标数量。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Description

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

input output
4 7
6 3

典型的思维问题啊~~要注意的这句话,就出来了 红字标的

还要考虑 两个数中含有0的情况

post code:


#include<stdio.h>
int main()
{
   int a,b,sum;
   while( scanf("%d %d",&a,&b)!=EOF )
   { 
    if(a!=0&&b!=0)  
       {
       sum=a+b-1;
       printf("%d %d\n",sum-a,sum-b);       
       } 
    else {              //这是其中一个含有0的情况
           sum=a+b; 
           printf("%d %d\n",sum-a,sum-b);
         
         }   
   }    
    
}



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值