zju acm 1007

(转载)

#include<stdio.h> 

int   main() 

 long   k; /*   dummy   summation   variable   */ 
 long   n; /*   number   of   terms   to   sum   */ 
 double   kd; /*   double   version   of   k   */ 
 double   x; /*   the   variable   */ 
 double   sum; /*   used   for   computation   summations   */ 
 double   px,   p1; /*   psi(x)   and   psi(1)   */ 
 double   dpx; /*   value   of   the   first   accelerated   series   at   x   */ 
 double   dp2; /*   value   of   the   first   accelerated   series   at   2   */ 
 double   ddpx; /*   value   of   the   second   accelerates   series   at   x   */ 
 long   i; /*   counter   for   elements   of   table   */ 
 
 p1   =   1.0; 
 dp2   =   0.25; 
 n   =   5000; 

 /*   loop   for   the   2001   table   entries   */ 
 for   (i=0;   i<2001;   i++   ) 
 { 
  x   =   i   *   0.001; 
  
  /*   sum   second   accelerated   series   */ 
  sum   =   0.0; 
  for(   k=1;   k<n;   k++   ) 
  { 
   kd   =   k; 
   sum   +=   1.0/(kd*(kd+1)*(kd+2)*(kd+x)); 
  } 
  ddpx   =   (2.0-x)*sum; 
  
  /*   get   the   value   of   the   first   accelerated   series   */ 
  
  dpx   =   (1.0-x)*(dp2+ddpx); 
  
  /*   get   value   of   original   series   */ 
  
  px   =   p1+dpx; 
  
  printf("%5.3f   %16.12f/n",   x,   px); 
 } 
 return   1; 

=================================================

很遗憾,WA ,不过测试数据都对得上 , 不知道哪里出问题了

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值