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 1355. Bald Spot Revisited

What'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)
Posted by Cybernetics Team 13 Apr 2005 22:26
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)
Posted by Zhihua Lai 5 Apr 2010 05:13


Edited by author 05.04.2010 06:38