https://uva.onlinejudge.org/external/121/12114.pdf
This is a adhoc problem . The hints for solving this problem is given below :
1 . Here in this problem the probability for bachelor marriages increasing is not possible as the smaller value is -1 .
2 . If B is equal to 1 or 0 then it also can not be determined .
3 . Otherwise when B>=S then the probability for a bachelor remains same because the because when B>S then the bachelor's number get finished but spinster remains so there'e no scope of increasing or decreasing bachelor's marriage probability .
4 . when B<S then the probability decreases as the number of spinster is less than the number of bachelor which is really hard to get all the bachelor married so the bachelor number remains which decreases bachelor's marriage probability .
A sample accepted solution is given below :
#include<bits/stdc++.h>
using namespace std;
int main()
{
int B,S,i=1;
while(scanf("%d%d",&B,&S)==2)
{
if(B==0 && S==0)
{
break;
}
else if(B==0 || B==1)
{
printf("Case %d: :-\\\n",i);
}
else if(B<=S)
{
printf("Case %d: :-|\n",i);
}
else if(B>S)
{
printf("Case %d: :-(\n",i);
}
i++;
}
return 0;
}
This is a adhoc problem . The hints for solving this problem is given below :
1 . Here in this problem the probability for bachelor marriages increasing is not possible as the smaller value is -1 .
2 . If B is equal to 1 or 0 then it also can not be determined .
3 . Otherwise when B>=S then the probability for a bachelor remains same because the because when B>S then the bachelor's number get finished but spinster remains so there'e no scope of increasing or decreasing bachelor's marriage probability .
4 . when B<S then the probability decreases as the number of spinster is less than the number of bachelor which is really hard to get all the bachelor married so the bachelor number remains which decreases bachelor's marriage probability .
A sample accepted solution is given below :
#include<bits/stdc++.h>
using namespace std;
int main()
{
int B,S,i=1;
while(scanf("%d%d",&B,&S)==2)
{
if(B==0 && S==0)
{
break;
}
else if(B==0 || B==1)
{
printf("Case %d: :-\\\n",i);
}
else if(B<=S)
{
printf("Case %d: :-|\n",i);
}
else if(B>S)
{
printf("Case %d: :-(\n",i);
}
i++;
}
return 0;
}
No comments:
Post a Comment