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 1157. Young Tiler

A little hint
Posted by Alexander Bovkun 26 Oct 2004 01:30
Amount of rectangles is equal to the number of divisiors of tiles count wich are no more than Square_Root(tiles count). So the part of code solving this problem may be the following:

  For L:=1 To 10000-K Do Begin
    DivisiorsCount:=1;
    For J:=2 To Trunc(Sqrt(L)) Do If L Mod J=0 Then
      Inc(DivisiorsCount);

    If DivisiorsCount=M Then Begin
      DivisiorsCount2:=1;
      For J:=2 To Trunc(Sqrt(L+K)) Do If (L+K) Mod J=0 Then
        Inc(DivisiorsCount2);

      If DivisiorsCount2=N Then Begin
        SoulutionExists:=True;
        Break;
      End;
    End;
  End;

You should output L+K if SolutionExists, 0 - otherwise.