Happy Coding

This blog is for my memorandum.

Happy Coding

This blog is for my memorandum

srm

TopCoder srm 708c PalindromicSubseq2

problem Problem Statement A palindrome is a string that reads the same forwards and backwards. For example, “abba” and “racecar” are palindromes. An odd palindrome is a palindrome with an odd length. For example, “racecar” is an odd palind…

TopCoder srm 708b BuildingStrings

problem The score of a string is its length multiplied by the number of different characters in the string. For example, the score of “abbcdxc” is 7 * 5 = 35. This is because the length of this string is 7 and there are five different char…

TopCoder srm 708a SafeBetting

problem Limak is in a casino. He has b dollars. He wants to have at least c dollars (to be able to buy flowers for a girl he likes). In order to achieve that, he must win the money he’s missing. The casino allows guests to risk some of the…

div2 srm 704 hard ModEquationEasy

Problem Statement You are given the s n, K, and v. Consider the following modular equation with n variables: (x[0] * x[1] * x[2] * ... * x[n-1]) mod K = v. How many solutions does it have? Formally, we want to find the number of sequences …

srm704 middium ConnectedComponentConstruction

Problem Statement Any undirected graph can be decomposed into connected components. Two vertices u and v belong to the same connected component if we can travel from u to v by following a sequence of zero or more consecutive edges. The siz…