UVa12114 - Bachelor Arithmetic(水题)

本文探讨了一个社区中未婚男女比例变化如何影响任意单身男性结婚概率的问题。通过数学模型简化实际问题,分析了不同未婚人数比例下,举行婚礼后单身男性结婚概率的变化趋势。

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

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  or 1 (The value that is smaller). So when a marriage ceremony occurs the probability becomes  or 1 (The value that is smaller). But of course if the denominator becomes zero the probability cannot be determined. Whether this new probability  is greater than the previous one () 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                            Output for Sample Input

10 10

2 3

3 2

0 0

Case 1: :-|

Case 2: :-|

Case 3: :-(

 



题意:已知是s,b,求(s-1)/(b -1)是比s/b大还是小,当然b和b-1不能等于零

思路:b=1,b-1=0,输出为:-\

           s >= b,保持不变

          s < b,减小

#include <cstdio>

using namespace std;

int b, s;
int cas = 1;

bool input()
{
	scanf("%d%d", &b, &s);
	
	if (b == 0 && s == 0) return false;
	
	return true;
}

void solve()
{
	printf("Case %d: ", cas++);
	if (b == 1) {
		printf(":-\\\n");
	} else if (s >= b) {
		printf(":-|\n");
	} else {
		printf(":-(\n");
	}
}

int main(int argc, char **argv)
{
	#ifndef ONLINE_JUDGE
		freopen("e:\\uva_in.txt", "r", stdin);
	#endif
	
	while (input()) {
		solve();
	}

	return 0;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

kgduu

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值