|
|
back to boardWhat's wrong? (Test 2) Posted by vlad 13 Apr 2005 20:48 var i,ans,n:longint; a,b:array[1..1000] of longint; begin readln(n); for i:=1 to n do readln(a[i],b[i]); for i:=1 to n do begin if a[i]=1 then begin if b[i]=1 then writeln(1) else writeln(0); end else begin ans:=0; while b[i] mod a[i] =0 do begin b[i]:=b[i] div a[i]; inc(ans); end; writeln(ans); end; end; readln; end.
Re: What's wrong? (Test 2) Your code is wrong. For 2 72 it outputs 3; the solution is 5: 2 -> 4 -> 8 -> 24 -> 72 Re: What's wrong? (Test 2) Edited by author 05.04.2010 06:38 |
|
|