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 1083. Factorials!!!

Why WA? Help me!!
Posted by korol andrey 7 Nov 2002 22:03
There is my program :
{@judge_id:15324hh 1083 pascal}
var ans,l,k,n,i:longint;str:string;
begin
  read(n);readln(str);l:=0;
  for i:=1 to length(str) do
    if str[i]='!' then l:=l+1;
  if l>n
     then writeln(n)
     else
       begin
         ans:=n;
         while (n>0) do
           begin
             n:=n-l;
             if n>1 then ans:=ans*n;
           end;
       end;
  writeln(ans);
end.
Please, help me.
Re: Why WA? Help me!!
Posted by ECUST Multistar 8 Nov 2002 04:23
Have you test you program?????

There was a small bug ,but which can be found by simple test.

There was the correct program...

See Line (*******)
It should there hehe
Good luck next time.
Bye..
var ans,l,k,n,i:longint;str:string;
begin
  read(n);readln(str);l:=0;
  for i:=1 to length(str) do
    if str[i]='!' then l:=l+1;
  if l>n
     then writeln(n)
     else
       begin
         ans:=n;
         while (n>0) do
           begin
             n:=n-l;
             if n>1 then ans:=ans*n;
           end;
******  writeln(ans);
       end;

end.