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 1071. Nikifor 2

Wrong answer test(6) Why?Help me+++++
Posted by Виктор Крупко 3 Apr 2005 23:19
program de;
   var
   a,n,i,r,x,y,step,j:longint;
   q:boolean;
   s1,s2,s:string;
begin
  step:=1;
  q:=false;
  read(x);
  read(y);
  repeat
    s1:='';
    s2:='';
    n:=x;
    inc(step);
    repeat
     i:=n mod step;
     n:=n div step;
     str(i,s);
     s1:=s+s1;
    until n=0;
    r:=y;
    repeat
     i:=r mod step;
     r:=r div step;
     str(i,s);
     s2:=s+s2;
    until r=0;
    j:=1;
    for i:=1 to length(s1) do
     if (s1[i]=s2[j]) and (j<>length(s2)+1) then inc(j);
    if j=length(s2)+1 then q:=true;
  until (step=x+1) or q;
  if q then writeln(step)
  else writeln('No solution');
end.
Re: Wrong answer test(6) Why?Help me+++++
Posted by Burunduk1 4 Apr 2005 00:16
For test 11 10
Your program writes 11
My AC program writes 'No solution'
Systems of calculation from 2 up to 16 or .....
Posted by Виктор Крупко 4 Apr 2005 00:58
Re: Systems of calculation from 2 up to 16 or .....
Posted by Burunduk1 4 Apr 2005 01:35
My AC program uses bases from 2 to 100000
How????
Posted by Виктор Крупко 4 Apr 2005 02:12
How to organize translation in other system of calculation, it is more 9
Re: How????
Posted by Burunduk1 4 Apr 2005 02:44
Part of my AC program:

leny = lenx = 0;
while (x > 0)
  ax[lenx++] = x % base, x /= base;
while (y > 0)
  ay[leny++] = y % base, y /= base;

x, y - decimal numbers
base - system of calculation
ax[], ay[] - x and y in new system
lenx, leny - its lengths