| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1001 人关注过本帖
标题:求这一道编程题答案
取消只看楼主 加入收藏
丰田甜
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2018-4-18
结帖率:100%
收藏
已结贴  问题点数:10 回复次数:0 
求这一道编程题答案

Three players, A, B, and C play a dice game, each player rolls two dice.

(The points of 2*3 = 6 dice should be set and stored in advance)

PART I:

Assume that each player can only see the points of his/her own two dice, simulate their game process.

Rules of PART I:

Starting from player A, the following steps are performed in turn.

First, the two dice thrown by the player A are output (indicating that A sees his/her dice), and then two numbers a and b are required to be input to represent A's guess for all dice, which means the number of b point dices in total is at least a.

Then it's the next player B's turn. After seeing his own dice, B can choose to enter 0 0 (two zeros) for "I don't believe" or to enter a new pair of numbers c and d, which means he/she guesses "there are at least c d points in all dice", where c,d must satisfy c≥a, and when c=a, d>b.

The game continues until someone input 0 0 (two zeros).

Optional rules:1 point dice can be regarded as any number of points.

For example:

O: A's turn: A has 2 and 1
I: 2 4
O: B's turn: B has 3 and 2
I: 2 3
O: Invalid input.
O: B's turn: B has 3 and 2
I: 3 2
O: C's turn: C has 2 and 5
I: 3 5
O: A's turn: A has 2 and 1
I: 4 2
O: B's turn: B has 3 and 2
I: 0 0

If someone (let's say player B above) enters 0 0 (two zeros), then show all 2 * 3 = 6 dice, determine the current player's "unbelieving" is right or wrong to judge the loser of the game: Assume that the previous player's input is x y. If the number of dice in y points is less than x (in a total of 6 dice), then the previous player (A) loses, otherwise, the current player (B) loses.

For example:

O: A's turn: A has 2 and 1
I: 2 4
O: B's turn: B has 3 and 2
I: 2 3
O: Invalid input.
O: B's turn: B has 3 and 2
I: 3 2
O: C's turn: C has 2 and 5
I: 3 5
O: A's turn: A has 2 and 1
I: 4 2
O: B's turn: B has 3 and 2
I: 0 0
O: All dices: 2 1 3 2 2 5
Loser is A. (Without optional rules)

Loser is B. (With optional rules)



PART II:

Play this game from the perspective of God, i.e. you can see all of the 6 dice.

Rules of PART II:

Observe all 6 dice and output the optimal combination of a and b, which means it  will certainly  be wrong for any other player to guess again.

For example:

O: All dices: 2 1 3 2 2 5
Best answer: 3 2 (Without optional rules)

Best answer: 4 2 (With optional rules)

注:

O: 用例输出,I: 用例输入,不必写在程序输出里

要求体现代码的良好风格、友好界面、算法和代码的高执行效率等。

其他可选部分:例如,可选择2-5之间的数字作为游戏人数及骰子个数等。

开放时间:    2018年04月02日 星期一 12:00
截止时间:    2018年04月21日 星期六 00:00
上传一个文件
跳过 导航
导航
我的主页
搜索更多相关主题的帖子: player and the for input 
2018-04-18 15:03
快速回复:求这一道编程题答案
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015121 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved