Naim_Hasan's blog

By Naim_Hasan, 5 months ago, In English,

At first thanks to Arpa who has written a very clean and fast library for handling big size number in C++. With it, i added sqrt and pow function. Also overloaded post++, post-- operator. And instead of writing "bigint", we wrote "Int" so that it become easy to write and understand.

The modified code now can handle all these operation given below:

+, -, *, /, %, =, >, < ; +=, -=, *=, /=, %=, ==, !=, >=, <= ; ++pre, post++, --pre, post-- ; pow(a,b), sqrt(a), max(a,b), min(a,b) ; [ Here a is Int type and b is Int or other integer type ]

Here is the latest code.

https://github.com/NaimHasanPappu/Algorithm/blob/master/BigInteger.cpp

To check if the library is working smoothly, try This Problem

Read more »

 
 
 
 
  • Vote: I like it
  • +65
  • Vote: I do not like it

By Naim_Hasan, 6 months ago, In English,

I generated all answer for 2 <= R <= 5 and 2 <= C <= 5.

But got stuck in 2nd part.

These are my observation when Row >=2 && Column > 5

When row is 2

We set 1st pointer to cell 1,1 and 2nd pointer to cell 2,4. Then we just move forward as much as can.

Next we set 2nd pointer to 2,1. If N is even then 1st pointer = ( 1 , (N/2)+1 ); else 1st pointer = ( 1 , ((N+1)/2)+1 ); Again we just move forward as much as can.

[ Its valid for all 2 x N when N > 5 ]

When row is 3 and N is even

We set 1st pointer to cell 1,1 and 2nd pointer to cell 2,4. Then move forward as much as we can. Then 1st pointer = (1, (N/2)+1) and 2nd pointer = (3,1); Again move forward as long as we can. Lastly 1st pointer = (2,1) and 2nd pointer = (3, (N/2)+1) and move forward as long as we can. [ Remember N is Even]

When row is 3 and N is odd [ This part is little tricky ]

1st pointer = (1, 1); 2nd pointer = (3, (N+1)/2 + 1); Move forward. 1st pointer = (1, (N+1)/2); 2nd pointer = (2, 1); Move forward. 1st pointer = (3, 1); 2nd pointer = (2, (N+1)/2 + 1); Move forward.

Now our main problem is to solve all 2 x N and 3 x N sub_grid. Here i got stuck badly. Lets say we are given a 5 x 10 grid. We can see it as 2 x 10 and 3 x 10 sub_grid. But after solving each sub_grid we have to merge them together. Because in 3 x 10 if a cell is (2,5), then in actual grid it will be (4,5).

Read more »

 
 
 
 
  • Vote: I like it
  • -21
  • Vote: I do not like it

By Naim_Hasan, history, 7 months ago, In English,

Update: Solved. Special thanks to mello

Hello,

I was solving this https://codeforces.com/contest/1/problem/B

I have write one function to convert an Alphabet number into decimal number.

For example BC turns into 55. Similarly RZ becomes 494.

Here is my implementation https://ideone.com/2J0hCq

But i am facing problem to do the reverse.

For 55, my code shows BC which is right but for 494 it shows S@ which is wrong.

Here is my implementation https://ideone.com/OuUJD3

I found that the problem is causing when input is a multiple of 26.

Help needed.

Read more »

 
 
 
 
  • Vote: I like it
  • -14
  • Vote: I do not like it