Showing posts with label SPOJ. Show all posts
Showing posts with label SPOJ. Show all posts

Thursday, July 7, 2011

SPOJ IKEYB - I-Keyboard

Problem Link: https://www.spoj.pl/NSUDP/problems/IKEYB/

Description for this problem is really long. In short -
Given the set of keys on a keypad, a set of letters to assign on those keys sequentially and each letters' frequency on a dictionary, you have to design an optimal keypad layout (assign letters to keys) such that overall typing price is lowest. The price is determined as the sum of the prices of each letter. The price of a letter is a product of the letter frequency (Fi) and its position on the key.

Sunday, July 3, 2011

SPOJ PT07X - Vertex Cover

Problem Link : https://www.spoj.pl/problems/PT07X/

This is a classic dynamic programming problem. We'll need to find minimal vertex cover of an unweighted, undirected tree.

Friday, December 10, 2010

SPOJ QTREE2

I'm back after a long break; longer than I anticipated. I was reading a Topcoder tutorial on Range Minimum Query (RMQ) and Lowest Common Ancestor (LCA) problems. Here's a comparison table of the algorithms presented in the tutorial -

Thursday, December 2, 2010

SPOJ MMOD29

Problem Link : http://www.spoj.pl/problems/MMOD29/en/

I was searching some problems that would require modular inverse / Chinese remainder theorem / Extended Euclidean algorithm. This problem requires the simplest case of modular inverse when the numbers in question are co-prime.

The problem in short
Find the sum of divisors of the number 2004^X mod 29 [1<=X<=10000000].
So, first we need to find the sum of divisors of an arbitrary number N. Let prime factorization of N is -