1 December 2014

Problem:

Rohit, Neelabh and Priya are planning a holiday trip together, but all of them wants to go to different destinations.They decided to roll a regular dice and the person having highest score wins and all will go to his/her destination for holiday. First Rohit and Neelabh play their dice. Priya now wants to calculate chances of her win. If Priya got maximum score and it is a tie with neelabh or Rohit then too Priya will win. Print in form m/n where m and n cannot be furthur divided ie 3/6 should be 1/2

Input Format:

T=number of test cases
A B(score of Rohit and Neelabh)

Output Format:

N lines containing probability

None

6
1 1
2 1
2 3
4 2
4 5
6 3

1/1
5/6
2/3
1/2
1/3
1/6

Explanations:

for case 1. whatever output Priya gets she will win. So ans is 6/6 ie 1/1

Solution:

chomp(\$t=<STDIN>);
for(\$i=0;\$i<\$t;\$i++)
{
chomp(\$in=<STDIN>);
\$in=~ / /;
\$a=\$`;
\$b=\$';
if(\$a<\$b){\$a=\$b;}
@arr=('0/0','1/1','5/6','2/3','1/2','1/3','1/6');
push(@out,\$arr[\$a]);
}
foreach(@out)
{
print "\$_\n";
}

Tips:

better to use arrays if number of output are limited.