|
|
вернуться в форумWhy I got Crash? Послано Jizhu3 23 дек 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? 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 июл 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; } |
|
|