|
|
back to boardmy formula n=k*(k+1)/2+1 in this position consist 1 else 0 Re: my formula I wrote that Re: my formula Posted by Izverg 15 Aug 2007 12:16 Я ничего не понял Shunmadim Misunderstanding Re: my formula Posted by TimoX 16 Aug 2007 16:48 I can't understand how you use N in your solution. N is only number of elements and nothing more. Maybe, I understand you wrong. Re: my formula Posted by TIA 15 Oct 2007 21:02 if 8k-7 is a squre then a[i]=1 else a[i]=0 Re: my formula Can I ask how could you find that? So beautiful solution Re: my formula The thing is that the sequence of positions of '1' in 1101001000... can be represented as (N*(N-1)/2+1). You can find this out by yourself or turn to http://oeis.org/classic/ So let's try to check whether an input A is a position of '1'. N*(N-1)/2 + 1 = A; N^2 - N + 2 - 2*A = 0; N is natural, so solution is: N = 1/2 * (1 + sqrt(8*A - 7)); So, A is a position if sqrt(8*A-7) is natural. Re: my formula k=sqrt((n-1)*2+0.0); if (n*(n+1)==(n-1)*2) cout<<1<<" "; else cout<<0<<" "; |
|
|