Page 1 of 1

10232 - Bit-wise Sequence

Posted: Sat May 18, 2002 9:38 pm
by Caesum
Can someone explain this problem to me please ? It gives the sample input and output:
Sample Input
0
1
2
31
32

Sample Output
0
1
2
1073741824
3
Shouldnt the sequence be 0,1,2,4,8,16,32,3,5,6,9,.....
in which case 32 is 6th and not 3rd as in the sample ? and 31 would not be that far in to the sequence....... Or am I completely misunderstanding this ?

Posted: Sat May 18, 2002 10:14 pm
by Ivan Golubev
Looks like you've exchanged input and output -- the 31th number of sequence is 1073741824, the 32nd number is 3, etc.

Posted: Mon Sep 16, 2002 6:03 am
by ithamar
I dont understan the input - output for this problem. Can anybody explain me why the number 1073741824 is the number 31 in the sequence (not 30 as i believe that should be).

I believe that all the numbers in the sequence between 1 and 30 are 1, 2, 4, 8, 16, 32, .... , 1073741824. But in this way 1073741824. is the number 30 not 31. What is wrong about my reasoning.

Thanxs in advance.

Posted: Mon Sep 16, 2002 12:40 pm
by Adrian Kuegel
If you use this sequence, the 30th number is 536870912, the 31th number is 1073741824. Perhaps generate you a list with a program, you will see it.

Posted: Mon Oct 28, 2002 7:25 pm
by solver
umm... I'm feeling quite clueless attempting this problem. :roll:

10232 -- is this the method?

Posted: Sat Nov 02, 2002 2:08 am
by solver
I've been thinking about 10232 (Bitwise Sequence), and the only way I could think of doing it was to

Taking 2 to be the only prime number with one 1 in its bin. representation,

1. generate all combinations of two 1s (with 1 in the last placeholder, as even numbers are not to be checked), and check them for primality.
2. Do the same for three 1s, four 1s, .. and so on, UNTIL we get the Nth prime number.


This approach is basically trying all combinations (serialwise however), and doesn't seem quite right if the time limit is less.

Is there any obvious number theory trick I'm missing ( a hint will do ). At least someone can confirm if I'm on the right track?

Thanks

Posted: Wed Nov 13, 2002 3:01 pm
by solver
Ulan Degenbayev wrote:How did you attached primes to this problem?
May be you have mixed up some problems?
You are right. I mixed up this problem with another one I saw. And misreading this one, I assumed one has to form a list of prime numbers in ascending order of B(n). That was confusing me a lot. :)

Now that the question is clear to me, the solution seems straightforward. Thanks.

10232 - Bit-wise sequence

Posted: Sun Sep 28, 2003 8:53 am
by Shahab
Hi everybody,

I have solved the problem #10232, but I got WA for it. It solves the sample input and my samples in the right way and I really can't understand the problem behind it.

Can anyone give me some sample input and output plz?

Thanks in advance,
Shahab Tasharrofi

Posted: Sun Sep 28, 2003 9:49 am
by Larry
Pretty much random:

Input:

Code: Select all

0
1
2
31
32
6123512
852412
123125
67658153
214155
2147483647
5623674
Output:

Code: Select all

0
1
2
1073741824
3
147227152
1099186184
135856144
1247429124
57624
2147483647
100730919

Posted: Sun Sep 28, 2003 10:30 am
by Shahab
Thanks for your inputs Larry, but altough it can solve them in the right way, i got WA another time :( , I'm really getting disappointed of this problem :-?

Shahab Tasharrofi

Posted: Sun Sep 28, 2003 10:35 am
by Shahab
ok, let me put my code here, I'll be graceful if you could have a brief look at it :

[pascal]
program P10232;
type Int=LongInt;
var A:array [-1..31,-1..31] of Int;
Bit:array [0..31] of Byte;
function Solve(n:Int):Int;
var i,b,k:Int;
begin
i:=0;
while n>=0 do
begin
n:=n-A[31,i];
Inc(i);
end;
Dec(i);
n:=n+A[31,i];
b:=31;
repeat
if n>=A[b-1,i] then
begin
n:=n-A[b-1,i];
Bit:=1;
Dec(i);
end
else
begin
Bit:=0;
end;
Dec(b);
until b<=0;
for i:=31 downto 1 do
k:=k shl 1+Bit;
Solve:=k;
end;
var i,j,n,k:Int;
begin
A[-1,0]:=0;
A[-1,-1]:=0;
for i:=0 to 31 do
begin
A[i,-1]:=0;
A[i,0]:=1;
for j:=1 to i-1 do
A[i,j]:=A[i-1,j-1]+A[i-1,j];
A[i,i]:=1;
end;
while not Eof(Input) do
begin
ReadLn(n);
k:=Solve(n);
WriteLn(k);
end;
end.
[/pascal]

Posted: Wed Aug 02, 2006 7:23 pm
by daveon
Hi,

I do not know pascal but here are some boundary IO's:

input:

Code: Select all

0
1
31
32
496
497
4991
4992
36456
36457
206367
206368
942648
942649
3572223
3572224
11460948
11460949
31621023
31621024
75973188
75973189
160645503
160645504
301766028
301766029
508019103
508019104
773201628
773201629
1073741823
1073741824
1374282018
1374282019
1639464543
1639464544
1845717618
1845717619
1986838143
1986838144
2071510458
2071510459
2115862623
2115862624
2136022698
2136022699
2143911423
2143911424
2146540998
2146540999
2147277279
2147277280
2147447190
2147447191
2147478655
2147478656
2147483150
2147483151
2147483615
2147483616
2147483646
2147483647

output:

Code: Select all

0
1
1073741824
3
1610612736
7
1879048192
15
2013265920
31
2080374784
63
2113929216
127
2130706432
255
2139095040
511
2143289344
1023
2145386496
2047
2146435072
4095
2146959360
8191
2147221504
16383
2147352576
32767
2147418112
65535
2147450880
131071
2147467264
262143
2147475456
524287
2147479552
1048575
2147481600
2097151
2147482624
4194303
2147483136
8388607
2147483392
16777215
2147483520
33554431
2147483584
67108863
2147483616
134217727
2147483632
268435455
2147483640
536870911
2147483644
1073741823
2147483646
2147483647

Posted: Sun Jan 06, 2008 11:57 am
by Bunda001
Hi, i would need that program - can someone please send here solved program in C++? thank you very much... or can send on Bunda001@seznam.cz