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 1091. Tmutarakan Exams

Can anybody help me?
Posted by AIT 29 Dec 2002 19:43
This is my program. I hope you will help to understand why i get WA.
Var k, s: longint;
    i, g, ji: longint;
    z: real;
    gg: boolean;
function ciznpk(nn, kk: longint): real;
var j: longint;
    an: real;
    dis: boolean;
begin
     if nn<kk then begin ciznpk:=0; exit; end;
     if nn = kk then begin ciznpk:=1; exit; end;
     an:=1;
     dis:=false;
     if kk>nn-kk then dis:=true;
     if dis then
     for j:=kk+1 to nn do
         an:=an*j;
     if not dis then
     for j:=nn-kk+1 to nn do
      an:=an*j;
     if not dis then
     for J:=2 to kk do
         an:=an / j;
     if dis then
     for j:=2 to nn - kk do
         an:=an / j;
     ciznpk:=an;
end;
Begin
     z:=0;
     read(k, s);
     for I:=2 to s do
     begin
          g:=(s) div i;
          gg:=false;
          for ji:=i-1 downto 2  do
          if i mod ji = 0 then begin gg:=true; break; end;
          if not gg then
          begin
          z:=z+ciznpk(g,k);
          for ji:=i-1 downto 2 do
          begin
               z:=z-ciznpk(g div ji,k)
          end;
          end;
     end;
     if z>10000 then
     z:=10000;
     write(trunc(z));
End.