| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1487 人关注过本帖
标题:一道有趣的难题
只看楼主 加入收藏
神vLinux飘飘
Rank: 13Rank: 13Rank: 13Rank: 13
来 自:浙江杭州
等 级:贵宾
威 望:91
帖 子:6140
专家分:217
注 册:2004-7-17
收藏
 问题点数:0 回复次数:29 
一道有趣的难题
神vLinux飘飘的翻译:
考虑 0,1,2,...,N (N+1个整数),N为奇数. 玩家有操作者和程序组成. 操作者先喊,然后在程序和操作者之间交替进行.所有整数都只能被喊一次. 操作者记录所有被喊过的数字,并且随即喊一个尚未被喊过的数字.现在问题是:设计一个程序,它会喊一个没有被喊过的整数.然而程序不允许去记录那些数被喊过.除非那个数正好被操作者喊出.

英文原文:
(A simple game) Consider 0, 1, 2, ..., N (N +1 integers), where N is odd. The players consist
of a dealer and a computer program. The dealer makes the first call, and the calls alternate between the dealer
and the program. No integer can be called more than once. The dealer keeps track of all the integers called,
and he randomly calls an integer not yet called. Now the problem is to design the program, so that it will also
call an integer not yet called. However, the program is not allowed to remember what have been called, except
for the one just called by the dealer.

不一定要你写出代码,有个思路就好。
难就难在,program得以任何方式存储那些被喊过的数字,那这个程序应该如何去“想”一个数,并且让“想”出的那个数尽量是没被提出过的....否则program就会输掉和dealer的比赛。当所有的数字被提出后,program一次错误都没犯下那就判是program赢~~!


大家想想,我觉得这几乎是不可能...这是香港大学的大二的一道普通的题目,还不是能附加分数的那种
搜索更多相关主题的帖子: 难题 
2006-02-11 17:20
aiyuheng
Rank: 1
等 级:新手上路
威 望:1
帖 子:656
专家分:0
注 册:2006-1-12
收藏
得分:0 
一定要让程序赢吗?如果是这样好象没可能!

when i want to ask anyone,i will ask myself first.
2006-02-11 17:46
woodhead
Rank: 3Rank: 3
等 级:新手上路
威 望:9
帖 子:1124
专家分:0
注 册:2005-7-18
收藏
得分:0 

程序是否知道范围?

如果知道,如果你是程序,我喊0, 你喊N, 我喊N-m, 你喊m......


2006-02-11 17:50
神vLinux飘飘
Rank: 13Rank: 13Rank: 13Rank: 13
来 自:浙江杭州
等 级:贵宾
威 望:91
帖 子:6140
专家分:217
注 册:2004-7-17
收藏
得分:0 

to aiyuhen: 程序不一定要赢啊~~

to woodhead: 程序肯定知道范围,但是程序不能提已经提过的数字


淘宝杜琨
2006-02-11 18:19
aiyuheng
Rank: 1
等 级:新手上路
威 望:1
帖 子:656
专家分:0
注 册:2006-1-12
收藏
得分:0 

那操作者可以记数而程序却不可以,这对程序不公平啊.我想这样程序肯定会输的.
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <time.h>

int main(void)
{
int i,ra,xy,n,num;
scanf("%d",&num);
for(i=0; i<num; i++)
{
scanf("%d",&n);
ra=random(num);
if (ra==n)
{
xy=random(1);
if (xy==1)
{
ra=n+1;
}
else
{
ra=n-1;
}
}
printf("%d\n", ra);
}
getch();
return 0;

}


when i want to ask anyone,i will ask myself first.
2006-02-11 18:24
神vLinux飘飘
Rank: 13Rank: 13Rank: 13Rank: 13
来 自:浙江杭州
等 级:贵宾
威 望:91
帖 子:6140
专家分:217
注 册:2004-7-17
收藏
得分:0 

你能不能想个办法,让你的program能获得更大的胜算


淘宝杜琨
2006-02-11 18:27
aiyuheng
Rank: 1
等 级:新手上路
威 望:1
帖 子:656
专家分:0
注 册:2006-1-12
收藏
得分:0 

program将要喊出的数可以说是随机的!因为它只知道deal just call,so it can know the num.then 在N中program失败的可能是1/(N-1)而且这个值无论如何也
没法减少,因为它没有记忆.
我想说怎么都是随机的,应该没什么可以使它有更大胜算的算法 
这是我的观点
i can't input my chinese char.!!!!!!


when i want to ask anyone,i will ask myself first.
2006-02-11 19:00
woodhead
Rank: 3Rank: 3
等 级:新手上路
威 望:9
帖 子:1124
专家分:0
注 册:2005-7-18
收藏
得分:0 
请仔细想想我上面说的

2006-02-11 19:23
神vLinux飘飘
Rank: 13Rank: 13Rank: 13Rank: 13
来 自:浙江杭州
等 级:贵宾
威 望:91
帖 子:6140
专家分:217
注 册:2004-7-17
收藏
得分:0 
.....我想了下.....好象有点道理,是不是我把这个问题想得太难了?

淘宝杜琨
2006-02-11 19:47
aiyuheng
Rank: 1
等 级:新手上路
威 望:1
帖 子:656
专家分:0
注 册:2006-1-12
收藏
得分:0 

#include <stdlib.h>
#include <stdio.h>

int main(void)
{
int i,n,ra,N;
scanf("%d",&N);
for(i=0; i<N; i++)
{
scanf("%d",&n);
ra=N-n;
printf("%d\n", ra);
}
getch();
return 0;

}
原来关键在于是奇数,总是对称的,这样程序不就会一直赢?呵呵!
woodhead真聪明!


when i want to ask anyone,i will ask myself first.
2006-02-11 19:54
快速回复:一道有趣的难题
数据加载中...
 
   



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

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