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 1055. Combinations

Please Help! Why WA?! Code included!
Posted by Grebnov Ilya[ISPU] 3 Oct 2002 23:02
VAR
  N, M, I : LongInt;
  Prim : ARRAY[1..10000] OF LongInt;
  Res : ARRAY[1..10000] OF LongInt;
  PrimC, P : LongInt;
  FUNCTION Simple(C : LongInt) : Boolean;
  VAR
    I : LongInt;
  BEGIN
    Simple := False;
    FOR I := 2 TO Round(Sqrt(N)) DO
      IF C MOD I = 0 THEN Exit;
    Simple := True;
  END;
BEGIN
  FillChar(Res, SizeOf(Res), 0);
  FillChar(Prim, SizeOf(Prim), 0);
  Read(N, M);
  PrimC := 0;
  IF N = 0 THEN BEGIN Write('0'); Halt; END;
  FOR I := 2 TO N DO
    IF Simple(I) THEN
      BEGIN
        Inc(PrimC);
        Prim[PrimC] := I;
      END;
  FOR I := 1 TO PrimC DO
    BEGIN
      P := Prim[I];
      REPEAT
        Res[I] := Res[I]+(N DIV P)-(M DIV P)-(((N-M) DIV P));
        P := P*Prim[I];
      UNTIL N DIV P = 0
    END;
  P := 0;
  FOR I := 1 TO PrimC DO
    IF Res[I] <> 0 THEN Inc(P);
  Write(P);
END.
Re: Please Help! Why WA?! Code included!
Posted by Orshanskiy Sergey 4 Nov 2002 05:41
Try entering 6 5