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 1209. 1, 10, 100, 1000...

my formula
Posted by turalSatol 26 Feb 2006 12:20
n=k*(k+1)/2+1 in this position consist 1 else 0
Re: my formula
Posted by turalSatol 26 Feb 2006 12:21
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
Posted by zam_sabina 22 Feb 2010 00:33
Can I ask how could you find that? So beautiful solution
Re: my formula
Posted by Artem Khizha [DNU] 27 Jul 2010 15:42
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
Posted by Andy_spb 20 Oct 2011 16:16
k=sqrt((n-1)*2+0.0);
if (n*(n+1)==(n-1)*2) cout<<1<<" ";
else                  cout<<0<<" ";