← Back to topics
Topic

Buka Problem...

p
pK-lst
Howdy guys,can someon tell me why i can't pass Test 6,i am pretty sure my code is working fine. Can you give me any hint why it doesnt work,please help. Thanks in advance :)
h
halil
1000000000000000000000000000000
*
10000000000000000000000000000000000

Note, a and b are not integers.
I think that checker not work right.
p
pK-lst
@Halil,i tried using float,long int,double,but it still doesnt work,which variable type should i use ?
h
halil
char[100]. Read again text of task.
p
pK-lst
Hmm,i didn't understood that part,i can't solve it,i may try solve it later :)
h
halil
Task difficulty = 2.

1000000000000000000000000000000
*
10000000000000000000000000000000000
=
10000000000000000000000000000000000000000000000000000000000000000


1000000000000000000000000000000
+
10000000000000000000000000000000000
=
10001000000000000000000000000000000
d
demjan0001
implement big numbers ...
p
pK-lst
Wait,i need to limit the output to 100 chars ?
d
demjan0001
???
well you need big numbers in this task ...
so integer goes to 2^32 and that is 10 digits,
but in this task number can has 100 digits ...
so input can be:
10000...000 // (10^100)
*
10000...000 // (10^100)
and solution is
10000...000 // (10^200)
p
pK-lst
So how can i make it accept more then 10 digits ?
d
demjan0001
ok ...
let's take for example 1 number
1234567
so you can save it in array of integer with 7 places ...
let say that digit[] is array of integer
so then we can put that number in array like this
digit[0] = 1
digit[1] = 2
digit[2] = 3
and so on ...
digit[6] = 7

// sometimes is better to save number in array in reverse order ...
so digit[0] = 7, digit[1] = 6, ... , digit[6] = 1 ...
but it is on you how you more like and how is easier to implement for you

and we can implement functions that can work with big numbers ...
such as multiplication, addition ...
try to think how you can implement those function:
BigNumber Multiplication( BigNumber a, BigNumber b );
BigNumber Addition( BigNumber a, BigNumber b );
where BigNumber is a structure or class:
class BigNumber {
bool negativ;
int digit[MaxDigits];
int numberOfDigits;
}
d
demjan0001
hint about implementation:
do it like you are doing it on paper ...
1234 * 56
-------------------
7404
+ 6170
-------------------
69104
h
halil
Easy to solve without big number aritmetics.
k
karakondzula
Just read it one more time. ( ... potency of 10 ... )
d
demjan0001
i haven't read task, i have just read this topic so i supposed that it is problem with big numbers ...
if number is potency of 10 then you don't need big numbers ...
h
halil
@ Aleksandar S.(pK-lst)

http://zadaci.pastebin.com/m639c424a
p
pK-lst
Ohh,i see now,thank you halil,later i will try solve it on my own :)
p
pK-lst
@Fahrudin can you add me on MSN ?
E-Mail : alek.stankovski@live.com