Stone Scissors Cloth Game

Source: Internet
Author: User

Describe

Stone-scissors-cloth is a game played by two people. Suppose there are two people A and B, and everyone chooses stone, cloth or scissors independently. Choose the cloth to win the choice of stone, choose scissors to win the choice of cloth, choose the stone to win the choice of scissors, choose the same neither win nor lose.
n individual participation, everyone with each other than K round stone-cloth-scissors game, a total of up to race k*n* (n-1)/2 games. Your job is to calculate the average of each person's win, which is defined as w/(w+l), where W is the number of winning fields, and L is the number of lost fields.

Input

The input has multiple test cases. The first line of each test case is n,k (1≤n≤1000, 1≤k≤10000), n is the number of participants, and K is the number of matches per person. For each match, it is represented by a line that contains four integers: p1,m1,p2,m2. The two men in the game, m1,m2 respectively, are their gestures ("Rock", "scissors", or "paper"). End with a 0 representation of the input.

Output

For each participant output a row, give them the average number of wins, the result is reserved three decimal places. If the winning average number of fields is variable, the output is "-". Output a blank line between the two test cases.

Sample input

2 4
1 Rock 2 paper
1 Scissors 2 Paper
1 Rock 2 Rock
2 Rock 1 Scissors
2 1
1 Rock 2 paper
0

Sample output

0.333
0.667

0.000
1.000
1#include <iostream>2 using namespacestd;3 4 intMain ()5 {6     intM, N, I, p1, p2,ying[10005],shu[10005],t=0;7     Chara[Ten], b[Ten];8      while(Cin>>m &&m)9     {TenCin>>N; One         if(t) Aprintf"\ n"); -Memset (Ying,0,sizeofying); -Memset (Shu,0,sizeofshu); the          for(i =1; I <= m*n/2; i++) -         { -scanf"%d%s%d%s",&p1,a,&p2,b); -             if(a[0]==b[0]) ; +             Else if(a[0]=='R'&&b[0]=='s'|| a[0]=='s'&&b[0]=='P'|| a[0]=='P'&&b[0]=='R') -             { +ying[p1]++; Ashu[p2]++; at             } -             Else  -             { -ying[p2]++; -shu[p1]++; -             } in         } -          for(i =1; I <= m; i++) to         { +             if(ying[i]==0&&shu[i]==0) -printf"-\n"); the             Else *printf"%.3lf\n",(1.0*ying[i])/(ying[i]+shu[i])); $         }Panax Notoginsengt++; -     } the     return 0; +}

Stone Scissors Cloth Game

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.