首页
社区
课程
招聘
看来大家都喜欢智力题啊,我出个稍微难一点的吧
2005-11-2 10:38 7135

看来大家都喜欢智力题啊,我出个稍微难一点的吧

RoBa 活跃值
16
2005-11-2 10:38
7135
有两个数a和b (1<a<b). M先生知道a*b的值,S先生知道a+b的值,两个有如下对话:
M先生说:我不知道a和b的值
S先生说:我也不知道,而且一开始我就知道你不知道
M先生说:我现在知道a和b的值了
S先生说:我现在也知道a和b的值了

给定x和y (2<=x,y<=550),求所有满足对话场景的(a,b)且x<=a<b<=y.假设二位先生足够聪明且没有撒谎。

ps:这是一次ACM欧洲分区赛的题目,请编程解决

[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课

收藏
点赞0
打赏
分享
最新回复 (10)
雪    币: 200
活跃值: (17)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
baolike 2005-11-2 11:14
2
0
不会~~~
雪    币: 200
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
chinarrr 2005-11-2 11:26
3
0
第一题不懂意思,a、b是整数吗?
雪    币: 216
活跃值: (40)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
阵雨 2005-11-2 12:33
4
0
翻译得丢三落四,我来贴原版

Problem C
Secret Numbers
Problem
Two natural numbers a and b are chosen (1<a<b). Person M is told the multiple of a and b (a*b), and person S is told the sum of a and b (a+b). The discussion between M and S goes like this:
M: I do not know the numbers a and b.
S: I do not know them either, but I knew you would not know them.
M: Now I know the numbers!
S: Now I know them, too!

Input
The input file contains pairs of natural numbers x and y (2<=x<y<=550), one pair per line. The input is guaranteed to be correct.

Output
For each pair x, y, find all pairs of a and b, such that x<=a<b<=y and that the given discussion is possible. Write these pairs in a single line, and finish that line with "no more pairs." if there are a and b found in the given range, or write simply "no pairs." if there are not. Separate the numbers of a pair with a comma, terminate each pair with a semi-colon, and separate different pairs with a blank after the semi-colon, as shown in the example below.

Sample Input
2 10
2 20

Output for the Sample Input
no pairs.
4,13; no more pairs.
雪    币: 401
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
不羁少年 2005-11-2 15:21
5
0
我感到这二个题好相少点非学重要的东西啊!我是想不出来了!
雪    币: 10095
活跃值: (1739)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
wzmooo 2005-11-3 02:03
6
0
思路我都不会 编程就更不行了ioi就是强啊
雪    币: 209
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
datm 2005-11-3 11:17
7
0
M先生说:我不知道a和b的值
S先生说:我也不知道,而且一开始我就知道你不知道

我感觉这个问题有问题
a*b=M
a+b=S
S先生不肯能知道M先生不知道这a,b两数,S完全可以表达成两个素数相加
雪    币: 511
活跃值: (1223)
能力值: ( LV12,RANK:650 )
在线值:
发帖
回帖
粉丝
RoBa 16 2005-11-3 12:01
8
0
最初由 datm 发布
M先生说:我不知道a和b的值
S先生说:我也不知道,而且一开始我就知道你不知道

我感觉这个问题有问题
a*b=M
........


哥德巴赫猜想只对偶数成立吧。
比如说。。S=17 ?
雪    币: 209
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
datm 2005-11-3 13:37
9
0
最初由 RoBa 发布


哥德巴赫猜想只对偶数成立吧。
比如说。。S=17 ?

是足够大的和数,我搞错了.
雪    币: 298
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
tedrick 2005-11-8 22:57
10
0
晕~~~好久了。。看来。。。
请楼主正解
雪    币: 270
活跃值: (312)
能力值: ( LV9,RANK:330 )
在线值:
发帖
回帖
粉丝
henryouly 8 2005-12-16 00:53
11
0
记a+b为p,a*b为q

M先生说:我不知道a和b的值
=> 1) q不能唯一分解为两个素数的乘积。注意到条件1<a<b,因此a、b不能为1,如果q可以分解成两个素数,那只可能是a和b,没有第二种分解形式。换句话说,q至少有3个素因子(可重复)
   2) q不是某个素数的立方。否则可以马上推断出a为那个素数,b为他的平方

S先生说:我也不知道,而且一开始我就知道你不知道
=> 3) p的任何和式分解得到的数x,y,x*y都满足1) 2)。否则S先生不敢说M先生肯定不知道

M先生说:我现在知道a和b的值了
=> 4) q正好有三个素因子(且他们不全部相等)
   5) 把q分解为两个整数的积,在所有6种分解方法中,只有一种分解方式,两个乘数的和可以满足条件3)

S先生说:我现在也知道a和b的值了
=> 6) p的所有和式分解得到的x,y,只有一种构成的积可以满足条件4)和5)

这些条件不知道还能不能得到进一步结论。程序也不知道怎么写,如果模拟的话,S先生的那两句话得出的条件可能会导致TLE的,不知道怎么优化
游客
登录 | 注册 方可回帖
返回