ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1209. 1, 10, 100, 1000...

Help! My program got time limited!
Posted by Tang RZ 29 May 2004 14:53
This is my program:

var
  a:array [1..10000] of longint;
  flag,pd:boolean;
  one,k,n,jia:longint;

procedure work(k:longint;pd:boolean);
var
  t:longint;
  i:integer;
begin
  flag:=true;
  jia:=0;
  t:=0;
  if k<>1 then
  repeat
    inc(jia);
    t:=t+jia;
  until k-t<jia+1
  else flag:=false;
  if k-t=1 then flag:=false;
  if flag then write('0')
    else write('1');
  if pd=false then write(' ')
    else writeln;
end;

procedure init;
var
  i:integer;
begin
  read(n);
  for i:=1 to n do
    begin
      read(k);
      if i<>n then pd:=false
        else pd:=true;
      work(k,pd);
    end;
end;

begin
  init;
end.