|
|
вернуться в форумif input 100!!! what output? plz help if input 100!!! what output? Re: if input 100!!! what output? plz help Послано Sandro 12 июн 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 Man where you take 112? asked me plz! Re: if input 100!!! what output? plz help 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 Protch I DO it. Re: if input 100!!! what output? plz help Послано ZiV 10 янв 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 |
|
|