# FOUR QUARTERS

Description

Four Quarters is a game of chance played with, well, four quarters. Two people, called A and B, each flip two quarters each round. They each gain or lose points each round based on the following tables:

There is no difference between Heads/Tails and Tails/Heads. As you can see, the odds are stacked in Player A's favor. At the beginning of the game, each player has 0 points, and points accumulate as the game progresses. At the

end of the game, whichever player has the most points wins.

You must write a program that determines the probability that Player A will win, Player B will win, or they will tie, after a certain number of rounds. Assume that the coins are fair, i.e. that heads and tails are equally likely.

Input

There is no input file for this problem.

Output

Output a table that lists the probability that Player A will win, B will win, or they will tie, after each round for 1 to 20 rounds. The output for rounds 1 through 3 is given below.

Probabilities must be expressed as a percent, with 4 places after the decimal.

Sample Input

Sample Output

Round A wins B wins Tie

1 43.7500% 18.7500% 37.5000%

2 56.6406% 22.2656% 21.0938%

3 62.3535% 22.7051% 14.9414%

- 点赞
- 写回答
- 关注问题
- 收藏
- 复制链接分享
- 邀请回答

*1*条回答

#### 相关推荐

- 4年前回答 1 已采纳 Description Four Quarters is a game of chance played with, well, four quarters. Two people, called A and B, each flip two quarters each round. They each gain or lose points each round based on the following tables: There is no difference between Heads/Tails and Tails/Heads. As you can see, the odds are stacked in Player A's favor. At the beginning of the game, each player has 0 points, and points accumulate as the game progresses. At the end of the game, whichever player has the most points wins. You must write a program that determines the probability that Player A will win, Player B will win, or they will tie, after a certain number of rounds. Assume that the coins are fair, i.e. that heads and tails are equally likely. Input There is no input file for this problem. Output Output a table that lists the probability that Player A will win, B will win, or they will tie, after each round for 1 to 20 rounds. The output for rounds 1 through 3 is given below. Probabilities must be expressed as a percent, with 4 places after the decimal. Sample Input Sample Output Round A wins B wins Tie 1 43.7500% 18.7500% 37.5000% 2 56.6406% 22.2656% 21.0938% 3 62.3535% 22.7051% 14.9414%
- 4年前回答 1 已采纳 Charlie is a driver of Advanced Cargo Movement, Ltd. Charlie drives a lot and so he often buys coffee at coffee vending machines at motorests. Charlie hates change. That is basically the setup of your next task. Your program will be given numbers and types of coins Charlie has and the coffee price. The coffee vending machines accept coins of values 1, 5, 10, and 25 cents. The program should output which coins Charlie has to use paying the coffee so that he uses as many coins as possible. Because Charlie really does not want any change back he wants to pay the price exactly. Input Specification Each line of the input contains five integer numbers separated by a single space describing one situation to solve. The first integer on the line P, 1 <= P <= 10 000, is the coffee price in cents. Next four integers, C1, C2, C3, C4, 0 <= Ci <= 10 000, are the numbers of cents, nickels (5 cents), dimes (10 cents), and quarters (25 cents) in Charlie's valet. The last line of the input contains five zeros and no output should be generated for it. Output Specification For each situation, your program should output one line containing the string "Throw in T1 cents, T2 nickels, T3 dimes, and T4 quarters.", where T1, T2, T3, T4 are the numbers of coins of appropriate values Charlie should use to pay the coffee while using as many coins as possible. In the case Charlie does not possess enough change to pay the price of the coffee exactly, your program should output "Charlie cannot buy coffee.". Sample Input 12 5 3 1 2 16 0 0 0 1 0 0 0 0 0 Sample Output Throw in 2 cents, 2 nickels, 0 dimes, and 0 quarters. Charlie cannot buy coffee.
- 5年前回答 3 已采纳 代码错误![图片](https://img-ask.csdn.net/upload/201610/16/1476625596_399604.jpg)
- 回答 2 已采纳 On Laravel Eloquent, How can I define relation condition with something that not exist on the table but calculated from a value in the table. For example : quarters transactions _________ _________ _________ ___________ | name | desc | | id | date | _________ _________ _________ ___________ | 1 | Jan-Mar | | 1 | 2016-04-01 | | 2 | Apr-Jun | | 2 | 2016-05-01 | | 3 | Jul-Sep | | 3 | 2012-07-21 | | 4 | Oct-Dec | | 4 | 2014-01-31 | _________ _________ _________ ___________ It's work fine with this SELECT FROM transactions tx INNER JOIN quarters q ON q.name = ((MONTH(tx.date)+2)/3) Quarters.php <?php namespace App\Models; use Illuminate\Database\Eloquent\Model; class Quarters extends Model{ } Transactions.php namespace App\Models; use Illuminate\Database\Eloquent\Model; class Transactions extends Model{ public function quater(){ return $this->belongsTo('App\Models\Quarters' , '????', 'name') ; } } What should I define in my model in order to be able to do: Transactions::where("some_field", "some_value")->with("quater")->get() note: I want to do this without modify table structure.
- 6年前回答 2 已采纳 How to create a key as array in Go for map. For example in ruby I can implement it such: quarters = { [1, 2, 3] => 'First quarter', [4, 5, 6] => 'Second quarter', [7, 8 ,9] => 'Third quarter', [10, 11, 12] => 'Fourh quarter', } quarters[[1, 2, 3]] # => "First quarter" How the same will be looked in Golang ?
- 回答 2 已采纳 i have a page with 4 links namely 1st.php, 2nd.php, 3rd.php, and 4th.php. my index.php displays the 3rd.php as default. i also created a 404.php (error page) so that when a user edits the URL it will not redirect to the index.php, instead it will display the error page. the problem is when i open my index.php page, it displays the error page instead. need help. this is my code: <?php $quarters = array('Q1', 'Q2', 'Q3', 'Q4'); $quarter = 'Q3'; if(isset($_GET['quarter']) && in_array($_GET['quarter'], $quarters)) { $quarter = $_GET['quarter']; } switch($quarter) { case 'Q1' : $quarter = 'firstq2012.php'; break; case 'Q2' : $quarter = 'secondq2012.php'; break; case 'Q3' : $quarter = 'thirdq2012.php'; break; case 'Q4' : $quarter = 'fourthq2012.php'; break; } $pages = array('Q1','Q2','Q3','Q4'); if (in_array($_GET['quarter'], $pages)){ include_once $quarter; } else { header('Location: 404.php'); } ?>
- 10年前回答 4 已采纳 What i want to do, is display the last 8 quarters in an hour, one hour ago. I already have this: <?php echo date('d-m-Y H:i:s', strtotime('-1 hour')); ?> For example: Its now 14:46 (2:46 PM), so what i want, is this: 13:45 13:30 13:15 13:00 12:45 12:30 12:15 12:00 How can i get that?
- weixin_30349597的博客 题目意思是，AB两个人掷硬币，每次一个人掷两次，然后对应图标里面得分，要你输出前20回合 A赢，B赢，或是平均的概率 dp还是不怎么会，参考别人代码才敲出来的 1 #include<iostream>...
- woniupengpeng的博客 抛掷硬币，玩家A、B每轮分别抛两次硬币，每轮得分如图。求前20轮A赢，B赢，打平的概率。
- 10年前ivan_zjj的博客 题意：两个人在玩抛硬币的游戏，没回合抛两次，两次的结果不同，双方得到的分也是不同的，要求输出前20轮中，没回合A胜，B胜或是平局的概率。 算法：概率DP 分析：用dp[i][j][k] 来表示第i轮，A得的...POJ 1217 FOUR
- W-Jarvis的博客 Little Ruins is a studious boy, recently he learned the four operations! Now he want to use four operations to generate a number, he takes a string which only contains digits '1' - '9', and split ...
- 12年前Foursquare源码 里面登录的代码让我注释掉了，用的时候打开就行
- 12年前ZJU/zoj 题库上的部分题源码 本人博客： hi.baidu.com/xiaoxianxi_acm
- hzcyacom的博客 It is worth noting that among the four businesses of Foxit Software, the revenue contribution of PDF editors and readers has increased year by year, from 56.16% in 2016 to 77.98% in the first three ...
- 2年前weixin_30681615的博客 9. Show all the product brands for the past four quarters, highlighting brands that sold in the bottom 10 percent for that quarter. Cell properties are a convenient way to perform exception ...
- 2年前weixin_30868855的博客 1217 FOUR QUARTERS 递推 1218 THE DRUNK JAILER 送分题 1233 Street Crossing 搜索->BFS 1245 Programmer, Rank Thyself 送分题 1247 Magnificent Meatballs 送分题 1248 Safecracker 搜索 1250...
- lililingling1985的博客 It might be twenty-four hours since he had eaten, it might be thirty-six. He still did not know, probably never would know, whether it had been morning or evening when they arrested him. Since he was...
- G球的博客 return "four 15 minute quarters"; } } } = = = = = == = == = == = == = == = == = == = == = == = == = == = == = == = == = (3)namespace ConsoleAssemblyTest// 该项目添加了对 (1) 的...
- 9年前铁猴的博客 基数词 0 nought;zero;O 1 one ...4 four 5 five 6 six 7 seven 8 eight 9 nine 10 ten 11 eleven 12 twelve 13 thirteen 14 fourteen 15 fifteen 16 sixteen 17 seventeen 18 eighteen
- renfengjun的博客 the total sales fora year, each process handles one quarter of the year instead of a singleprocess handling all four quarters by itself. The improvement in performancecan be quite significant. ...