|
|
back to boardWA#48, pls help!!! Posted by Bobur 5 Mar 2008 15:43 i can't find my bug. give me test#48, thx. var x, n : integer; t : real; begin readLn(n); if n mod 10 = 7 then t := (ln(3)+(n - 2) * ln(2))/ln(10) else t := (ln(3)+(n-1) * ln(2))/ln(10); x := TRUNC(t); t := t - x; t := exp(t*ln(10)); if t < 1.5 then dec(x); writeLn(x); end. Edited by author 05.03.2008 22:39 Re: WA#48, pls help!!! Posted by Denis 10 Mar 2008 01:40 Could you explain your program ? How you get this formulas ? Thank you in advance ! Re: WA#48, pls help!!! Posted by Bobur 10 Mar 2008 21:16 if n is very big number then a[n] will be 2/3; lim(a[n]) = 2/3 when n->MAXnumber; you must continued fo'rmula, then you will have a[n] := (...)/2^(n-1); you must write this with 10^x (x-will be answer); like this 10^x = 2^(n-1); x =lg(2^(n-1)) => x = ln(2^(n-1))/ln(10); Re: WA#48, pls help!!! Posted by denton 10 Mar 2008 23:39 Hm, n ≤ 100000, but I've always thought that Integer in Free Pascal ≤ 32767... Anyway, I recommend you to switch Integer to Longint and Real to Extended. Re: WA#48, pls help!!! Posted by Bobur 11 Mar 2008 20:22 it doesn't work... Re: WA#48, pls help!!! Posted by Fox 11 Mar 2008 21:24 t := (ln(3)+(n-1) * ln(2))/ln(10) ... <- its really so if n mod 10 = 7 then t := (ln(3)+(n - 2) * ln(2))/ln(10) ... <- but i cant understand this rule if t < 1.5 then dec(x) ... <- is only? you realy must compare: +2/3/(2^n) and 1/3/(10^t) - when odd(n) -2/3/(2^n) and -2/3/(10^t) - when even(n) why its so? because now you must know will the remainder (+/-) 2/3/(2^n) corrupt the (t-1)-th digit of your diabolic number Edited by author 11.03.2008 22:18 thank you veryyy much!!! Posted by Bobur 11 Mar 2008 23:15 thanks a lot! with your help, now i've AC |
|
|