Tobby_And_Friends's blog

By Tobby_And_Friends, history, 8 years ago, In English

Problem name: Count LCM

Link: https://uva.onlinejudge.org/external/128/12888.pdf

Let's say n < m. Then the answer is for each integers i, from 1 to n, how many integers up to m are co-prime with i. I tried solving the problem but it got me a TLE. How do I optimize my solution? Any help is really appreciated.

Solution Link: http://ideone.com/mMoWMS

Full text and comments »

By Tobby_And_Friends, history, 8 years ago, In English

Problem link: https://www.hackerrank.com/challenges/digit-products

My solution: http://ideone.com/wXDPi3

I got a verdict of TLE. How can I optimize my code further? Any help is really appreciated.

Full text and comments »

By Tobby_And_Friends, history, 8 years ago, In English

Problem Link: https://uva.onlinejudge.org/external/124/12429.pdf

Any hints to solve the problem is really appreciated.

Full text and comments »

By Tobby_And_Friends, history, 8 years ago, In English

I recently studied Mo's algorithm on trees. Please help me out with some problems to practice. Any help is really appreciated.

Full text and comments »

By Tobby_And_Friends, history, 8 years ago, In English

I do understand the query, i.e, query of type 1 A means adding 1 to the value at A, query of type 2 X means how many queue has pilgrims of length >= X and query of type 3 Y means to subtract 1 from each of the queues having >= Y pilgrims. I'm just not sure how to process my original arrays so that I can easily update using BIT. Any hint will be really appreciated.

Problem Link: http://www.spoj.com/problems/TEMPLEQ/

Full text and comments »

By Tobby_And_Friends, history, 8 years ago, In English

Problem Link: http://www.spoj.com/problems/SEGSQRSS/

While I do understand that the merge operation can be deduced from the equation (a + b)^2 = a^2 + b^2 — 2ab I could not specifically figure out how would I formulate the merge operation. Any help is really appreciated.

Full text and comments »

By Tobby_And_Friends, history, 8 years ago, In English

Problem Name: KQUERY — K-query

Problem Link: http://www.spoj.com/problems/KQUERY/

My solution: http://ideone.com/4COpOu

verdict: TLE

How do I further optimize my solution?

Any help is really appreciated.

Full text and comments »

By Tobby_And_Friends, history, 8 years ago, In English

Problem Link: http://www.spoj.com/problems/NUMTSN/

My solution: http://ideone.com/7fKLqx

Any help is really appreciated.

Full text and comments »

By Tobby_And_Friends, history, 8 years ago, In English

Problem Link: http://codeforces.com/problemset/problem/731/F

Solution Link: http://ideone.com/3UYOmF

I got WA in test case 7. What is wrong with my solution?

Full text and comments »

By Tobby_And_Friends, history, 8 years ago, In English

I just read this tutorial today https://threads-iiith.quora.com/Dynamic-Programming-on-Trees-Tutorial Please help me with some problems to solve.

Full text and comments »

By Tobby_And_Friends, history, 8 years ago, In English

UVA 13085

Problem Name: Forming Teams

Problem link: https://uva.onlinejudge.org/contests/364-bb2339ba/13085.pdf

I understand that for a number n I need to find out all of its divisors and then I need to find out the possible combinations for each divisor. I could not figure out how to come up with the combinations. Any help is really appreciated.

Full text and comments »

By Tobby_And_Friends, history, 8 years ago, In English

Problem Name: Maximum number, GCD condition (ANUGCD)

Problem Link: https://www.codechef.com/MARCH14/problems/ANUGCD

My implementation: http://ideone.com/TXHpuW

Verdict: Wrong Answer

Anyone please help me out to find why did I get a WA. Thanks in advance.

Full text and comments »

By Tobby_And_Friends, history, 8 years ago, In English

UVA 13083

Name: Yet another GCDSUM

Link: https://uva.onlinejudge.org/external/130/13083.pdf

I did get the idea that I'll initially compute all the divisors of N using prime factorization & backtracking but I'm stuck in how to compute the gcd of the divisor pairs with a better complexity than O(n^2). Any help is really appreciated.

Full text and comments »

By Tobby_And_Friends, history, 8 years ago, In English

How do I go on into solving probability/expected value problems? I'm really struggling with such kind of problems. I feel I understand the solution partially and I am not able to formulate the whole solution. Any help, suggestion, step-wise guidelines for practice is really appreciated.

Full text and comments »

By Tobby_And_Friends, history, 8 years ago, In English

I tried to implement the problem using segment tree and multisets. I got a verdict of TLE. How can I optimize my code? Or is there a better solution?

Problem link: http://www.spoj.com/problems/KQUERY2/en/

Solution link: http://ideone.com/gDAmUW

Full text and comments »