poj 1900 Game
2015-03-26 09:17
405 查看
题解在
http://wangmingxuan.cn/?post=26
Game
Description
There is a legend that mathematicians in the XVIII century enjoyed playing the following game.
The game was played by three mathematicians. One of them was the game master. First of all, the game master declared some positive integer number N . After that he chose two different integer numbers X and Y ranging from 1 to N and told their sum to one player
and their product to the other player. Each player knew whether he was told the sum or the product of the chosen numbers.
After that the players in turn informed the game master whether they knew the numbers he had chosen. First the player who was told the sum said whether he knew the numbers, after that the player who was told the product did, and so on.
For example the dialog could look like this:
Game master: "Let N be 10".
After that he chooses two numbers ranging from 1 to 10 and tells their sum to player S and their product to player P.
Player S: "I don't know these numbers."
Player P: "I don't know these numbers."
Player S: "I don't know these numbers."
Player P: "I don't know these numbers."
Player S: "Oh, now I know these numbers. You have chosen 3 and 6."
Given N and M -- the number of times the players have said "I don't know these numbers", you have to find all possible pairs of numbers that could have been chosen by the game master.
Input
The first line of the input contains N and M (2 <= N <= 200, 0 <= M <= 100).
Output
First output number of possible pairs of numbers that could have been chosen by the game master from the range 1 to N if both players altogether had said "I don't know these numbers" M times. After that output these pairs in arbitrary
order, one on a line.
Sample Input
Sample Output
Source
Northeastern Europe 2003
http://wangmingxuan.cn/?post=26
Game
Time Limit: 1000MS | Memory Limit: 60000K | |||
Total Submissions: 806 | Accepted: 229 | Special Judge |
There is a legend that mathematicians in the XVIII century enjoyed playing the following game.
The game was played by three mathematicians. One of them was the game master. First of all, the game master declared some positive integer number N . After that he chose two different integer numbers X and Y ranging from 1 to N and told their sum to one player
and their product to the other player. Each player knew whether he was told the sum or the product of the chosen numbers.
After that the players in turn informed the game master whether they knew the numbers he had chosen. First the player who was told the sum said whether he knew the numbers, after that the player who was told the product did, and so on.
For example the dialog could look like this:
Game master: "Let N be 10".
After that he chooses two numbers ranging from 1 to 10 and tells their sum to player S and their product to player P.
Player S: "I don't know these numbers."
Player P: "I don't know these numbers."
Player S: "I don't know these numbers."
Player P: "I don't know these numbers."
Player S: "Oh, now I know these numbers. You have chosen 3 and 6."
Given N and M -- the number of times the players have said "I don't know these numbers", you have to find all possible pairs of numbers that could have been chosen by the game master.
Input
The first line of the input contains N and M (2 <= N <= 200, 0 <= M <= 100).
Output
First output number of possible pairs of numbers that could have been chosen by the game master from the range 1 to N if both players altogether had said "I don't know these numbers" M times. After that output these pairs in arbitrary
order, one on a line.
Sample Input
10 4
Sample Output
3 2 5 3 6 3 10
Source
Northeastern Europe 2003
相关文章推荐
- 【POJ 2484】A Funny Game 博弈找规律
- poj 1027 The Same Game(大模拟)
- poj 1753 Flip Game
- POJ 1694 An Old Stone Game ★(排序+树+递归)
- POJ 1753 Flip Game 暴力搜索(dfs加枚举)
- 搜索 - poj1753 Flip Game
- Flip Game POJ - 1753 bfs
- POJ 1738 An old Stone Game 石子合并之GarsiaWachs算法
- poj 3589 Number-guessing Game(水题)
- POJ 1027 The Same Game(模拟)
- poj2084 Game of Connections
- POJ2084—Game of Connections(c++高精度)
- poj 1753--Flip Game
- poj 2328 Guessing Game
- [poj] 2286 The Rotation Game || ID-DFS
- POJ 3688 Cheat in the Game(作弊博弈)
- 文章标题 POJ :1666 Candy Sharing Game(模拟)
- POJ 1678[I Love this Game!]题解
- POJ 2286 UVA 1343 The Rotation Game IDA*
- ZOJ1427 POJ1694 An Old Stone Game