| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 370 人关注过本帖
标题:求教,很简单题目,样例过了,但是提交提示错误,求高人指点迷津
只看楼主 加入收藏
huicpc0876
Rank: 2
等 级:论坛游民
帖 子:69
专家分:50
注 册:2009-7-24
结帖率:92.59%
收藏
已结贴  问题点数:20 回复次数:3 
求教,很简单题目,样例过了,但是提交提示错误,求高人指点迷津
题目:输入两个整数a b,用空格隔开,(2 ≤ a, b ≤ 1000 000). 0 0作为结束符。
      当整数a最大的素因子减去其他素因子(不重复)之和 大于 整数b最大素因子减去 其他素因子之和时候输出‘a’(没有引号),否则输出‘b’

Sample Input
10 15
30 20
0 0
 
Sample Output
a
b
 
我的代码:
#include"stdio.h"
int main()

{ unsigned long int a,b,n1,n2,sum1,sum2,i,j,max1,max2;
  while(scanf("%ld %ld",&a,&b)!=EOF)

  {if((a==0)||(b==0))  break;
    if((a<2)||(b<2))    break;
   
   sum1=0;n1=a;
    for(i=2;(i<=n1)&&(a>=i);i++)/*素数最小是2,最大是本身*/
    { if(a%i==0)
      {sum1+=i;max1=i;/*max来记录最大的素数,sum用来记录素数的和*/
       while(a%i==0)  {a=a/i;}/*假设i是素数,将i的倍数都过滤掉*/
       }}
  
   sum2=0;n2=b;
    for(j=2;(j<=n2)&&(b>=j);j++)
    { if(b%j==0)
      {sum2+=j;max2=j;
        while(b%j==0) {b=b/j;}
       }}
 
 /*printf("%ld*%ld*",max1,max2);*/
   if((2*max1-sum1)>(2*max2-sum2)) printf("a\n");
   else printf("b\n");
   
   }return 0;

   }

附上英文题目:
Problem description
Everlasting Sa-Ga, a new, hot and very popular role-playing game, is out on October 19, 2008. Fans have been looking forward to a new title of Everlasting Sa-Ga.
Little Jimmy is in trouble. He is a seven-year-old boy, and he obtained the Everlasting Sa-Ga and is attempting to reach the end of the game before his friends. However, he is facing diffculty solving the riddle of the first maze in this game — Everlasting Sa-Ga is notorious in extremely hard riddles like Neverending Fantasy and Forever Quest.
The riddle is as follows. There are two doors on the last floor of the maze: the door to the treasure repository and the gate to the hell. If he wrongly opens the door to the hell, the game is over and his save data will be deleted. Therefore, he should never open the wrong door.
So now, how can he find the door to the next stage? There is a positive integer given for each door — it is a great hint to this riddle. The door to the treasure repository has the integer that gives the larger key number. The key number of a positive integer n is the largest prime factor minus the total sum of any other prime factors, where the prime factors are the prime numbers that divide into n without leaving a remainder. Note that each prime factor should be counted only once.
As an example, suppose there are doors with integers 30 and 20 respectively. Since 30 has three prime factors 2, 3 and 5, its key number is 5 − (2 + 3) = 0. Similarly, since 20 has two prime factors 2 and 5, its key number 20 is 5 − 2 = 3. Jimmy therefore should open the door with 20.
Your job is to write a program to help Jimmy by solving this riddle.

 
Input
The input is a sequence of datasets. Each dataset consists of a line that contains two integers a and b separated by a space (2 ≤ a, b ≤ 106). It is guaranteed that key numbers of these integers are always different.
The input is terminated by a line with two zeros. This line is not part of any datasets and thus should not be processed.

 
Output
For each dataset, print in a line ‘a’ (without quotes) if the door with the integer a is connected to the treasure repository; print ‘b’ otherwise. No extra space or character is allowed.

 
Sample Input
10 15
30 20
0 0
 
Sample Output
a
b
搜索更多相关主题的帖子: 提示 高人 
2009-08-04 10:34
huicpc0876
Rank: 2
等 级:论坛游民
帖 子:69
专家分:50
注 册:2009-7-24
收藏
得分:0 
怎么都每人来挑战一下!~
2009-08-05 11:43
葡萄树
Rank: 2
等 级:论坛游民
帖 子:23
专家分:64
注 册:2009-8-3
收藏
得分:14 
有点看不懂题目。哎,要恶补英文了~
2009-08-05 12:22
huicpc0876
Rank: 2
等 级:论坛游民
帖 子:69
专家分:50
注 册:2009-7-24
收藏
得分:0 
回复 3楼 葡萄树
我上面有中文描述啊!~~
2009-08-05 14:05
快速回复:求教,很简单题目,样例过了,但是提交提示错误,求高人指点迷津
数据加载中...
 
   



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

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