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

Show all messages Hide all messages

Why I got Crash? Jizhu3 23 Dec 2001 14:40
My program is here:

var
   m,n,k:longint;
   min:longint;
function nums(a:longint):longint;
var
   i,tot:longint;
begin
     tot:=0;
     for i:=1 to trunc(sqrt(a)) do
     if a mod i=0 then inc(tot);
     nums:=tot;
end;
begin
     readln(m,n,k);
     for min:=1 to 10000 do
     begin
          if (nums(min)=n)and(nums(min-k)=m) then
          begin
               writeln(min);
               exit;
          end;
     end;
     writeln(0);
end.
Re: Why I got Crash? I have answers to all your questions :) 23 Dec 2001 15:55
min should be not less than k or ur program'll get crash because it
try to find square root of an negative integer :)
and so do i? ^oo^ 24 Jul 2002 09:53
#include <stdio.h>
#include <math.h>
int i,m,n,k;
int num(int num)
{
  int i,tot=0;
  for (i=1; i<=(int)sqrt(num); ++i)
    if (num%i==0) ++tot;
  return tot;
}
int main()
{
  scanf("%d%d%d",&m,&n,&k);
  for (i=k; i<10000; ++i)
    if ((num(i)==n)&&(num(i-k)==m))
    {
      printf("%d",i);
      exit(0);
    }
  printf("%d",0);
  return 0;
}