0

http://www.spoj.pl/problems/BISHOPS/

hey, Can any one please see this problem and tell me how to deal with number like 10^100 ? Please help me out as it is used in many many problems. thanks in advance to everyone.

Not Yet Answered # large number dealing

np complete 8 nmaillet 97 WaltP 2,905 nmaillet 97 WaltP 2,905 delta_frost Hey, so I wanna ask how I need to create a method who will remove word if in that word is 2 same chars. Example: "Potato" in this word there is a 2 "o" chars so this word will need to be removed. "Forum" in this word there is no ...

Hi I'm having a problem implementing a mini shopping cart drop down in the header to show the user all the products they have in their shopping cart. It seems the only solution for this is Ajax, and I've looked all over and can't find anything that I could possibly ...

0

http://www.spoj.pl/problems/BISHOPS/

hey, Can any one please see this problem and tell me how to deal with number like 10^100 ? Please help me out as it is used in many many problems. thanks in advance to everyone.

0

Actually you can solve the bishop problem by hand, first try for samller numbers then generalize the result. Its a common math olympiad problem.

Anyways, returning to your question, you can handle such number by linked list. You have to develop your own way to do operations like add, subtract etc on it. There are libraries to help you handle large numbers. One of them is GMP. You may check this out.

*Edited 4 Years Ago by np complete*

0

I'm not entirely sure what you are asking. You can iterate through an array in reverse like this:

```
for(i = size_of_array - 1; i >= 0; i--) {
...
}
```

Or refer to the array like this:

```
array[size_of_array - 1 - index] = some_value;
```

1

Enter it into a temporary input buffer. Then move it into place in your array.

np complete:you can handle such number by linked list.

Major overkill. Since the numbers must be kept sequential, why do you need a structure containing and **int** and a **pointer** and all that code to insert/delete/traverse nodes?

A simple array is the answer...

0

Assuming the number is a string (since it is greater than a 64-bit unsigned integer), you could do something like this:

```
char *smallStr, *bigStr;
size_t index, offset;
smallStr = "2345654345555556667777";
bigStr = (char*)calloc(100, sizeof(char));
/* This copies the null terminator from smallStr. Change to "100 - strlen(smallStr);" if you do not want the null terminator. */
offset = 99 - strlen(smallStr);
for(index = 99; index >= offset; index--)
bigStr[index] = smallStr[index - offset];
/* Pad bigStr with 0's */
for(index = 0; index < offset; index++)
bigStr[index] = '0';
```

Hope that's what you meant...

0

Depends on what you **need** to do. If you want to use "*pre-defined data types like java*", use java. If you want to use C, you need to use the data types C has. Or find a third-party library, such as the one already mentioned.

0

Unless you wish to use libraries to proceed/switch to C++ to use the BigInteger class,you would have to implement all arithmetic on character arrays and operate on them carefully.It will take a whole lot of coding and wastage of time since it is already implemented in Java/C++.

This article has been dead for over six months. Start a new discussion instead.

Recommended Articles

I don’t want at this stage work on a big separate project as I've already got plenty ...