10705 - The Fun Number System
Moderator: Board moderators
10705 - The Fun Number System
Is there a good algo to solve it? I think brute force would take much time.
Hint: think of the technique of "excess code".
7th Contest of Newbies
Date: December 31st, 2011 (Saturday)
Time: 12:00 - 16:00 (UTC)
URL: http://uva.onlinejudge.org
Date: December 31st, 2011 (Saturday)
Time: 12:00 - 16:00 (UTC)
URL: http://uva.onlinejudge.org
Oops.. It's actually NOT a programming technique. It's just a way to store integers in computers......
(Sorry if I've caused confusion
)
Check this out: http://library.thinkquest.org/26532/inside/coding/.
(Sorry if I've caused confusion

Check this out: http://library.thinkquest.org/26532/inside/coding/.
7th Contest of Newbies
Date: December 31st, 2011 (Saturday)
Time: 12:00 - 16:00 (UTC)
URL: http://uva.onlinejudge.org
Date: December 31st, 2011 (Saturday)
Time: 12:00 - 16:00 (UTC)
URL: http://uva.onlinejudge.org
hi.
I got ACCEPT, and I'll give you test data.
here is input:
And my output
Good luck!
I got ACCEPT, and I'll give you test data.
here is input:
Code: Select all
36
4
ppnn
10
4
nnpp
-10
4
pppp
10
4
ppnn
6
1
p
1
9
pnppnnnnn
332
11
pppnppnnnnn
332
3
ppp
0
2
nn
-2
9
ppppppppn
255
20
pppnnppnnnnpppnpnppp
894632
1
n
0
1
p
0
1
p
1
1
n
-1
3
ppp
4
4
pppp
15
3
pnp
-1
3
pnp
3
50
pnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
1
50
pnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
-1
50
nppppppppppppppppppppppppppppppppppppppppppppppppp
-1
64
ppppnnnpnppnpnnnppppppppppnnnpnpppppnnnpnppnpnnnppppppppppnnnpnp
3254335264364654723
64
ppppnnnpnppnpnnnppppppppppnnnpnpppppnnnpnppnpnnnppppppppppnnnpnp
-980195823579238788
64
ppppnnnpnppnpnnnppppppppppnnnpnpppppnnnpnppnpnnnppppppppppnnnpnp
4363049762604363426
64
ppppnnnpnppnpnnnppppppppppnnnpnpppppnnnpnppnpnnnppppppppppnnnpnp
-1351135325723452455
4
pppp
16
4
ppnn
-10
3
pnp
6
4
nnnn
10
1
n
1
8
nppnnnnn
332
2
nn
2
4
pppn
15
2
pp
4
1
n
1
Code: Select all
1110
1110
1010
1010
1
101110100
00101110100
000
10
100000001
11101101101011111000
0
0
1
1
100
1111
011
111
11111111111111111111111111111111111111111111111111
00000000000000000000000000000000000000000000000001
11111111111111111111111111111111111111111111111111
0011010101010111101110001101001001011101100001010111000010000111
0000111001101011101001010110101110000101010001001110111010001100
0100010110110100101010101110010010011101011011101010111011100110
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Impossible
Last edited by hiloshi on Sun Sep 26, 2004 12:04 pm, edited 1 time in total.
I hope you can understand my poor English.
Do you guys all handle this correctly?
It gave me some problems because (n+1)/2 or (n-1)/2 could give overflows. I used 'n/2+(n%2-1)/2' and 'n/2+(n%2+1)/2'.
Anybody else had problems with this? And is there a nicer way to do those calculations?
Code: Select all
Input:
2
64
nppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp
-9223372036854775808
64
nppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp
9223372036854775807
Code: Select all
Output:
1000000000000000000000000000000000000000000000000000000000000000
0111111111111111111111111111111111111111111111111111111111111111
Anybody else had problems with this? And is there a nicer way to do those calculations?
I solve this problem without using such things.
I just use my proof that if we have K and some string of 'p'-s and 'n'-s than the maximum number(max) which we can give minus minimum number(min) =2^k-1.And all numbers between min and max we can give.
I just use my proof that if we have K and some string of 'p'-s and 'n'-s than the maximum number(max) which we can give minus minimum number(min) =2^k-1.And all numbers between min and max we can give.
Last edited by Eduard on Fri Sep 03, 2004 1:23 pm, edited 1 time in total.
someone who like to solve informatic problems.
http://acm.uva.es/cgi-bin/OnlineJudge?AuthorInfo:29650
http://acm.uva.es/cgi-bin/OnlineJudge?AuthorInfo:29650
.
hi hiloshi
one test data is not correct.
The weight of most significant negabit (1ULL << 59)
is 576460752303423488. So, it's "Impossible".
one test data is not correct.
Code: Select all
64
ppppnnnpnppnpnnnppppppppppnnnpnpppppnnnpnppnpnnnppppppppppnnnpnp
-1351135325723452455
4
Code: Select all
1111010101000001110011011111010010001111110010111001110000101001
is 576460752303423488. So, it's "Impossible".
[/code]hiloshi wrote:hi.
I got ACCEPT, and I'll give you test data.
here is input:And my outputCode: Select all
36 4 ppnn 10 4 nnpp -10 4 pppp 10 4 ppnn 6 1 p 1 9 pnppnnnnn 332 11 pppnppnnnnn 332 3 ppp 0 2 nn -2 9 ppppppppn 255 20 pppnnppnnnnpppnpnppp 894632 1 n 0 1 p 0 1 p 1 1 n -1 3 ppp 4 4 pppp 15 3 pnp -1 3 pnp 3 50 pnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn 1 50 pnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn -1 50 nppppppppppppppppppppppppppppppppppppppppppppppppp -1 64 ppppnnnpnppnpnnnppppppppppnnnpnpppppnnnpnppnpnnnppppppppppnnnpnp 3254335264364654723 64 ppppnnnpnppnpnnnppppppppppnnnpnpppppnnnpnppnpnnnppppppppppnnnpnp -980195823579238788 64 ppppnnnpnppnpnnnppppppppppnnnpnpppppnnnpnppnpnnnppppppppppnnnpnp 4363049762604363426 64 ppppnnnpnppnpnnnppppppppppnnnpnpppppnnnpnppnpnnnppppppppppnnnpnp -1351135325723452455 4 pppp 16 4 ppnn -10 3 pnp 6 4 nnnn 10 1 n 1 8 nppnnnnn 332 2 nn 2 4 pppn 15 2 pp 4 1 n 1
Good luck!Code: Select all
1110 1110 1010 1010 1 101110100 00101110100 000 10 100000001 11101101101011111000 0 0 1 1 100 1111 011 111 11111111111111111111111111111111111111111111111111 00000000000000000000000000000000000000000000000001 11111111111111111111111111111111111111111111111111 0011010101010111101110001101001001011101100001010111000010000111 0000111001101011101001010110101110000101010001001110111010001100 0100010110110100101010101110010010011101011011101010111011100110 1111010101000001110011011111010010001111110010111001110000101001 Impossible Impossible Impossible Impossible Impossible Impossible Impossible Impossible Impossible Impossible