UVA12114 UVALive4055 Bachelor Arithmetic【水题】

So what effect does a marriage ceremony has on an arbitrary bachelor (boy)? Well it depends on his thought process and context: he can be happy or sad. But in general what a marriage ceremony does is that it decreases the number of both bachelor and spinster (Female Bachelor) by one in the community. And so marriage ceremony has an effect on the probability of marriage of a bachelor.
Let’s simplify things a bit as life is more complicated than what we want to admit. Suppose in a community there are B bachelors and S spinsters (Both B and S are strictly positive) and all of them are equally likely to be married with one another (ahem! a bachelor and a spinster of course) and marriage does not happen
outside the community. And so in this model the probability of getting married for any bachelor is S/B or 1 (The value that is smaller). So when a marriage ceremony occurs the probability becomes (S−1)/(B−1) or 1 (The value that is smaller). But of course if the denominator becomes zero the probability cannot be determined. Whether this new probability (S−1)/(B−1) is greater than the previous one ( S/B ) depends on the relative values of B and S (B > S, B = S or B < S). Given the number of bachelors and spinsters in a community your job is to find out whether or not the probability of marriage for any bachelor will increase or decrease in the community after a marriage ceremony has occurred.
Input
The input file contains at most 1000 lines of inputs. Each line contains two integers B and S (0 < B, S < 2000000001).
Input is terminated by a line containing two zeroes. This line should not be processed.
Output
For each line of input produce one line of output. This line should contain the serial of output followed by a ‘?’, ‘?’ or ‘?’ respectively (without the quotes) depending on whether or not the probability of marriage for a bachelor increases, decreases or remains same. If the desired probability after the marriage cannot be determined then produce the output ‘:-\’ (Without the quotes) instead.
Sample Input
10 10
2 3
3 2
0 0
Sample Output
Case 1: ?
Case 2: ?
Case 3: ?

问题链接UVA12114 UVALive4055 Bachelor Arithmetic
问题简述:(略)
问题分析
    给定s和b,判定(s-1)/(b -1)比s/b大还是小,自然要求b和b-1不能等于零。
    题目比较长,其实是水题。若b=1,那么b-1=0,则输出:-\;若s>=b则保持不变;若s<b则减小。
程序说明:(略)
参考链接:(略)
题记:(略)

AC的C++语言程序如下:

/* UVA12114 UVALive4055 Bachelor Arithmetic */

#include <iostream>

using namespace std;

int main()
{
    int b, s, caseno = 0;
    while(~scanf("%d%d", &b, &s) && (b || s)) {
            printf("Case %d: ", ++caseno);
            if(b == 1)
                printf(":-\\\n");
            else if(s >= b)
                printf(":-|\n");
            else
                printf(":-(\n");
    }

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值