|
|
вернуться в форумPlease Help! Why WA?! Code included! 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! Try entering 6 5 |
|
|