LSPITO - Help Conan ! (version 3)

Tác giả: RR

Ngôn ngữ: Pascal

{$R+,Q+}
uses math;
const
  FINP='';
  FOUT='';
  oo=1000000000000;
var
  f1,f2:text;
  n:int64;
  a:array[1..20000000] of int64;
  sl:longint;
procedure openF;
begin
  assign(f1,FINP); reset(f1);
  assign(f2,FOUT); rewrite(f2);
end;
procedure closeF;
begin
  close(f1); close(f2);
end;
procedure init;
var
  chuky:longint;
  i,now:int64;
begin
  sl:=1; a[1]:=0; i:=2; chuky:=3; now:=3;
  repeat
    inc(sl); a[sl]:=i;
    i+=chuky;
    if i>=now*now then
      begin
        inc(now);
        inc(chuky);
        inc(i);
      end;
  until i>oo;
end;
var
  mid:longint;
function find(l,r:longint):boolean; inline;
begin
  if (n<a[l]) or (n>a[r]) or (l>r) then exit(false);
  if a[l]=n then exit(true);
  if a[r]=n then exit(true);
  mid:=(l+r)>>1;
  if a[mid]=n then exit(true)
  else if n<a[mid] then exit(find(l,mid-1))
  else exit(find(mid+1,r));
end;
begin
  init;
  openF;
  while not eof(f1) do
    begin
      readln(f1,n);
      if find(1,sl) then writeln(f2,'Thu Uyen')
      else writeln(f2,'Conan');
    end;
  closeF;
end.

Download