设为首页 加入收藏

TOP

运用递归的方法求等比数列(一)
2013-07-23 09:06:47 来源: 作者: 【 】 浏览:273
Tags:运用 方法 等比 数列

  题目说明:

  Sumdiv

  Time Limit: 1000MS Memory Limit: 30000K

  Total Submissions: 10953 Accepted: 2592

  Description

  Consider two natural numbers A and B. Let S be the sum of all natural divisors of A^B. Determine S modulo 9901 (the rest of the division of S by 9901).

  Input

  The only line contains the two natural numbers A and B, (0 <= A,B <= 50000000)separated by blanks.

  Output

  The only line of the output will contain S modulo 9901.

  Sample Input

  2 3

  Sample Output

  15

  Hint

  2^3 = 8.

  The natural divisors of 8 are: 1,2,4,8. Their sum is 15.

  15 modulo 9901 is 15 (that should be output).

  Source

  Romania OI 2002

  个人感觉这题是很棒的,要熟悉性质,还要会用递归的方法求等比数列,那我们就来看一下具体操作步骤吧!

  [cpp]

  #include

  #include

  #include

  __int64 xiang[100000],xishu[100000];

  __int64 mod=9901;

  int main()

  {

  __int64 deal(__int64 p,__int64 n);

  __int64 i,j,n,m,s,t,top,res,key;

  while(scanf("%I64d %I64d",&n,&m)!=EOF)

  {

  if(n==0)

  {

  printf("0\n");

  continue;

  }

  memset(xiang,0,sizeof(xiang));

  memset(xishu,0,sizeof(xishu));

  for(i=2,top=0;i<=(int)(sqrt((double)(n))+0.01);)

  {

  if(n%i==0)

  {

  while(n%i==0)

  {

  xiang[top]=i; xishu[top]++;

  n=n/i;

  }

  }

   

首页 上一页 1 2 下一页 尾页 1/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇用STL的函数生成全排列 下一篇给n m的最大值最小的值

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: