POJ 1005(向后去整)

小数处理……

Program P1005;
const
   pi=3.1415926;
Var
   t,i,j:longint;
   x,y,s:double;
begin
   read(t);
   for i:=1 to t do
   begin
      read(x,y);
      s:=sqrt(x*x+y*y);
      s:=s*s*pi/2;
      s:=s/50;
      if trunc(s)<s then s:=trunc(s)+1
      else s:=trunc(s);
      writeln('Property ',i,': This property will begin eroding in year ',s:0:0,'.');

   end;
   writeln('END OF OUTPUT.');
end.

POJ 1068(找规律)

(+1;(-1,用sum表示当前的值,

当sum>=1时,w[i]=i-j+1;( j 表示最后加的一段的右边结点的序数)

Program P1068;
Var
   t,i,j,n:longint;
   p:array[0..20] of longint;
function w:longint;
var
   j,sum:longint;
begin
   if p[i]-p[i-1]>0  then exit(1);
   j:=i;
   sum:=0;
   while (true) do
   begin
      inc(sum,p[j]-p[j-1]);
      if sum>=1 then exit(i-j+1)
      else dec(sum);
      dec(j);
   end;
end;
begin
   read(t);
   p[0]:=0;
   while t>0 do
   begin
      read(n);
      for i:=1 to n-1 do
      begin
         read(p[i]);
         write(w,' ');
      end;
      read(p[n]);
      i:=n;
      writeln(w);
      dec(t);
   end;
end.

POJ 1003(小数处理?)

此题题目看了半天……才发现是水题

Program P1003;
var
   a:array[0..10000] of double;
   i,j:longint;
   n:double;
begin
   i:=1;
   a[0]:=0;
   while a[i-1]<5.2 do
   begin
      a[i]:=a[i-1]+1/(i+1);
      inc(i);
   end;
   read(n);
   while n<>0.00 do
   begin
      i:=0;
      while a[i]<n do inc(i);
      writeln(i,' card(s)');
      read(n);
   end;
   writeln;
end.