为什么错误200

P1035 [NOIP2002 普及组] 级数求和

ws_fuweidong @ 2015-08-10 20:37:59

var
  n,k:integer;
  sn:real;
begin
  read(k);
  n:=0;
  sn:=0;
  while sn<=k do
  begin
    n:=n+1;
    sn:=sn+1/n;
  end;
  write(n);
end.

by nonprocess @ 2015-08-10 21:12:57

@[url=/space/show?uid=8629]ws_fuweidong[/url] 错误编号200 除数为0


by skyair @ 2015-09-11 22:26:46

integer超了,换成longint就好了


by huangzhewer @ 2015-11-10 12:32:37

var n,k:longint;
     s:extended;
begin
  read(k);
  n:=1;
  while s<=k do
     begin
       s:=s+1/n;
        inc(n);
    end;
  write(n);
end.

by huangzhewer @ 2015-11-10 12:33:22

write(n-1);!!!!!!!!


|