题解 P1014 【Cantor表】

· · 题解

[color=red]枚举[/color]

呵呵!就是枚举

数据太小

O(N)能过

本题标程存在于1366题看程序写结果3中

而且那还有很多没必要的

标程如下


var i,j,k,n:longint;
begin
     readln(n);
     k:=1;
     i:=1;j:=1;
     while k<n do
     begin
          if (i=1) and (j mod 2=1) then inc(j)
          else if (j=1) and (i mod 2=0) then inc(i)
          else if (i+j) mod 2=0 then begin dec(i);inc(j);end
          else if (i+j) mod 2=1 then begin inc(i);dec(j);end;
          inc(k);
     end;
     writeln(i,'/',j);
end.