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 1261. Tips

if input 100!!! what output? plz help
Posted by Tolstobrov_Anatoliy[Ivanovo SPU] 8 Jun 2005 02:17
if input 100!!! what output?
Re: if input 100!!! what output? plz help
Posted by Sandro 12 Jun 2005 23:19
For example, 100 = 112 - 12.
112 and 12 have only digits 0 and 1 in 3-base record.

Good luck!
Re: if input 100!!! what output? plz help
Posted by Tolstobrov_Anatoliy[Ivanovo SPU] 23 Jun 2005 22:45
Man where you take 112?
asked me plz!
Re: if input 100!!! what output? plz help
Posted by Protsenko Sergey[Ivanovo SPU] 26 Jun 2005 23:40
I've solved in the following way:
1. i've found the representation of the given number in the 3-base system as the result - array of coefficients from the set [0, 1, 2]
2. every coef =2 converted to 3 (or +1 for the next coef).
if you still have questions mail to p_s_@list.ru

Re: if input 100!!! what output? plz help
Posted by Tolstobrov_Anatoliy[Ivanovo SPU] 13 Aug 2005 20:05

Protch I DO it.
Re: if input 100!!! what output? plz help
Posted by ZiV 10 Jan 2006 13:53
I had the same idea dut got WA1, with this code:
Var
 n,k,z,i : word;
 sum,x : int64;
 a :array[1..10000] of byte;
BEGIN
 Read(n);
 z := n;
 k := 1;
 while n <> 0 do
  Begin
   a[k] := n mod 3;
   n := n div 3;
   Inc(k);
  End;
 For n := 1 to 10000 do
  Begin
   if a[n] = 2 then
    Begin
     a[n] := 0;
     Inc(a[n+1]);
    End;
   if a[n] > 2 then
    Begin
     Inc(a[n+1],a[n] div 3);
     a[n] := a[n] mod 3;
    End;
  End;
 sum := a[1];
 For n := 2 to k+10 do
  Begin
   if a[n] <> 0 then
    Begin
     x := 1;
     For i := 1 to n-1 do
      x := x*3;
     Inc(sum,x*a[n]);
    End;
  End;
 if sum <> z then
  Writeln(sum,' ',sum - z)
 Else
  Write(0);
END.
I help you give me your email
Posted by ACM.Krupko_Victor[Ivanovo SPU] 11 Jan 2006 13:41