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 1036. Lucky Tickets

I cannot get AC!
Posted by Tang RZ 4 Jun 2004 18:39
This is my program:
var
  t,total,k:longint;
  n,s:integer;

procedure init;
begin
  read(n,s);
  total:=0;
  k:=0;
end;

procedure work;
var
  i:integer;
begin
  for i:=9 downto 0 do
    if (total+i<=s div 2)and(k<=n) then
      begin
        inc(k);
        total:=total+i;
        if (total=s div 2)and(k=n) then inc(t)
          else work;
        total:=total-i;
        dec(k);
      end;
end;

procedure print;
begin
  writeln(t*t);
end;

begin
  init;
  work;
  print;
end.
Use long arithmetic... :)
Posted by marina_ufa 5 Jun 2004 14:41
Re: Use long arithmetic... :)
Posted by Tang RZ 12 Jun 2004 18:43
What did you mean? I cannot get it! My English is poor!
Because the largest answer can as large as 50 digits.But one longint just could handle up to 2147483647.It is only 10 digits.
Posted by Y.Y.M. 13 Jun 2004 10:22