本程序将因子一起输出,只要答案自己更改
#include "stdio.h"
#include "math.h"
main()
{
long n,s,a,b,answer=0,i;
printf("please enter the n and s:");
scanf("%ld,%d",&n,&s);
for(i=0;i<=(int)sqrt(n);i++)
{
if(n%(i+1)==0)
{
a=i+1;
b=n/(i+1);
if(a!=b)
{ answer+=a+b;
answer=answer%s;
printf("%ld,%ld\n",a,b);
}
else
{ answer+=a;
answer=answer%s;
printf("%ld,%ld\n",a,b);
}
}
}
printf("the answer is %ld\n",answer);
}
[此贴子已经被作者于2007-3-19 13:36:02编辑过]