加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

UVA12114 UVALive4055 Bachelor Arithmetic【水题】

发布时间:2020-12-14 04:24:40 所属栏目:大数据 来源:网络整理
导读: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 ba

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: :-(

Regionals 2007 >> Asia - Dhaka

问题链接: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;
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读