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

why i am wrong?
Posted by IceWorld 19 Apr 2005 17:34
const
    max                =15;
    Prime           :array[1..max] of integer=(2,3,5,7,11,13,17,19,23,29,31,37,41,43,47);
var
    k,s             :integer;
    n,m                :integer;
    tot                :longint;

Procedure init;
begin
    readln(k,s);
end;

Function calc(n,m:integer):longint;
const
    Maxn               =50;
var
    i,j,k           :longint;
    tem             :longint;
    bool            :array[1..maxn] of boolean;
    num                :array[1..maxn] of integer;
begin
    fillchar(bool,sizeof(bool),true);
    k:=n-m;
    for i:=m+1 to n do
        num[i-m]:=i;
    for i:=1 to k do
        for j:=1 to n-m do
            if bool[j] and (num[i] mod j = 0) then
            begin
                num[i]:= num[i] div j;
                bool[j]:=false;
            end;
    tem:=1;
    for i:=1 to k do
    begin
        tem:=tem*num[i];
        if tem>10000 then begin calc:=10000; exit end;
    end;
    calc:=tem;
end;

Procedure work;
var
    i,j                :integer;
    tem                :longint;
begin
    tot:=0;
    for i:=1 to max do
        if prime[i]<=(s div k) then
        begin
            n:=s div prime[i];
            m:=k;
            tem:=calc(n,m);
            if tem=10000 then begin writeln(10000); halt end
            else inc(tot,tem);
            if tot>=10000 then begin writeln(10000); halt end;
        end;
    writeln(tot);
end;

begin
    init;
    work;
end.