1003散分啊。
Scenario
The game of gizilch has very simple rules. First 100 grapes are labeled, in nontoxic ink, with the numbers 1 to 100. Then, with a cry of ``GIZILCH!'', the referee fires the grapes up into the air with a giant gizilcher. The two players, who each start with a score of ``1'', race to eat the falling (or, shortly thereafter, fallen) grapes and, at the same time, multiply their scores by the numbers written on the grapes they eat. After a minute, the hungry squirrels are let loose to finish the remaining grapes, and each contestant reports his score, the product of the numbers on the grapes he's eaten. The unofficial winner is the player who announces the highest score.
Inevitably, though, disputes arise, and so the official winner is not determined until the disputes are resolved. The player who claims the lower score is entitled to challenge his opponent's score. The player with the lower score is presumed to have told the truth, because if he were to lie about his score, he would surely come up with a bigger better lie. The challenge is upheld if the player with the higher score has a score that cannot be achieved with grapes not eaten by the challenging player. So, if the challenge is successful, the player claiming the lower score wins.
So, for example, if one player claims 343 points and the other claims 49, then clearly the first player is lying; the only way to score 343 is by eating grapes labeled 7 and 49, and the only way to score 49 is by eating a grape labeled 49. Since each of two scores requires eating the grape labeled 49, the one claiming 343 points is presumed to be lying.
On the other hand, if one player claims 162 points and the other claims 81, it is possible for both to be telling the truth (e.g. one eats grapes 2, 3 and 27, while the other eats grape 81), so the challenge would not be upheld.
Unfortunately, anyone who is willing to referee a game of gizilch is likely to have himself consumed so many grapes (in a liquid form) that he or she could not reasonably be expected to perform the intricate calculations that refereeing requires. Hence the need for you, sober programmer, to provide a software solution.
Input
Pairs of unequal, positive numbers, with each pair on a single line, that are claimed scores from a game of gizilch.
Output
Numbers, one to a line, that are the winning scores, assuming that the player with the lower score always challenges the outcome.
Sample Input
343 49
3599 610
62 36
Sample Output
49
610
62
问题点数:50、回复次数:4Top
1 楼neight(巴哈)回复于 2004-07-01 08:25:36 得分 0
大家好,这是我做的浙大1003的答案,麻烦各位帮忙瞧瞧这样做妥不妥当。
#include "stdio.h"
int a[10000]={0};
int fill(int x1,int x2) // x1 is max,x2 is min
{
int i;
int false=0;
for(i=1;i<100;i++)
{
if((x2%i)==0&&(x2/i)>i&&(x2/i)<=100)
{
a[i-1]=i;
a[x2/i-1]=x2/i;
break;
}
}
for(i=2;i<=100;i++)
{
if((x1%i)==0&&(x1/i)>i&&(x1/i)<=100)
{
if(a[i-1]!=0)
{
if(!fill(a[i-1],a[i-1]))
false++;
}
else
{
a[i-1]=i;
}
if(a[x1/i-1]!=0)
{
if(!fill(a[x1/i-1],a[x1/i-1]))
false++;
}
else
{
a[x1/i-1]=x1/i;
}
if(false==0)
return 1;
}
}
return 0;
}
main()
{
int x1,x2;
scanf("%d%d",&x1,&x2); // the max must be putted into x1,and the other one must be putted into x2;
if(x1==x2)
{
printf("can not judge the answer!");
return;
}else if(x1>10000&&x2>10000)
{
printf("none of them are telling the truth!\n");
return;
}
if(fill(x1,x2))
printf("%d",x1);
else
printf("%d",x2);
}
Top
2 楼programfanny()回复于 2004-07-01 13:01:55 得分 0
收藏之,学习之,运用之...Top
3 楼nobush()回复于 2004-07-01 15:48:24 得分 40
如果有选手 吃了 48、47、46 ,另一选手吃了 50,51,52 是不是都超过了 10000?
我理解错了吗?
另外:
if(false==0)
return 1;
看起来多别扭, 把逻辑关系换一下, 直接 return false 岂不更好?Top
4 楼mmmcd(超超)回复于 2004-07-01 16:37:17 得分 10
http://acm.zju.edu.cn/forum/viewtopic.php?t=984Top




