CodeMat'22 Problem Ideas

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

CodeMat’22 Problem Ideas

Div4 A/B

1. Divisible
Alice’s favorite number is A, Bob’s favorite number is B. Alice and Bob will be happy if A
is divisible by B or B is divisible by A. Will Alice and Bob be happy?

2. String
Given a string and a character. Find if the character is present or not in the string.

Div3 A/B

1. Indivisible
Harsh received three numbers on his birthday N,x,y. Now he wants to find the sum of all
distinct numbers between [1, N], which is neither divisible by x nor by y.

2. Strength of Shinobis

There are n shinobis in each village. The strength of a village is the sum of the strength
of their shinobis. Given the strength of all shinobis of all the the five villages, output the
villages having maximum and minimum strength.
It is guaranteed that all villages have different strength.

Div 2 A

1. Max Xor

Given an array A, of size N. You can do at most one operation on array A: select any
index i (1 <= i <= N) and replace A[i] (1 <= A[i] <= 2^30) by K (0 <= K <= 2^30).
After at most 1 operation find the maximum pairwise xor possible.
Div2 B

1. Bomb The Terrorists

There are n terrorists in a square-shaped red alert area of side length 1 unit. You have
bombs that kill all the terrorists in a square-shaped region of side length 1/k unit. Find the
maximum integral value of k such that there is at least 1 bomb that kills at least m
terrorists.

Note: You have to consider all possible arrangements of terrorists in the square-shaped
area.

2. Game of Two Numbers

You are given 2 positive integers a and b. Consider integers x, y, u, v where

x=u=a

y=v=b

You have to perform the following operations :

if x>y change x→ x-y and u→ u+v

if y>x change y→ y-x and v→ v+u

if y=x stop performing any more operations

Find the value of (u+v) - (x+y) when you finally stop performing the operations.

Div2 C
1. Yes or No
A number is good if it can be expressed as ax+by+5z, where x, y, and z must be
non-negative integers. Given q queries, in each query given an integer p, find whether p
is good or not.

2. Digits Removal
You are given a very large number n which can have up to 10^5 digits.

You can remove as many digits from the number as you want (zero or more), and the
remaining digits concatenate to form a new number.
You are asked the sum of all possible resulting numbers after your move.

Note that, it is possible to obtain the same number using a different set of removals, they
should be considered different.
For example, if you are given 626203, we can get 6203 on removing 626203 as well as
626203.

Since the answer can be very large, print it modulo 10^9 + 7.

Div2 D

1. Squeezing Array
Harsh received an array which is a permutation of length n on his birthday. He wondered
what could be the minimum length of the array if he applies the following operation any
number of times:
If a[i] < a[i+1] then he agrees to remove any one of a[i] or a[i+1] (after the removal, the
remaining parts are concatenated).

Now he wants you to help him find the minimum possible length of the given array using
the above-mentioned operation.

The operation can be performed any number of times on any element. (n <= 500)

2. Piyush’s Challenge
Given an integer K, an array A is defined as follows:
A[0] = 0, A[1] = A[2] = K.
For i > 2, A[i] = expected value of ((A[j]*A[i-1-j] + A[j+1]*A[i-j])/ K ) , where 0 < j < i-1.

Given q queries, each query contains an integer x, output A[x] modulo (1e9+7).
if(A[x] = (p/q)), output p*(q_inverse) modulo (1e9+7), x <= 1e18.

Div2 E

1. Expected Value
You are given a sequence A consisting of N positive integers.

Let f(S) be defined for a non-empty subsequence S as follows:

f(S) = g/(l+1)

where g is the GCD of the elements of the subsequence S and l is the length of the
subsequence S.

Find the expected value of f(S) if all the non-empty subsequences are equiprobable.

3. Permutation Sum
You are given a permutation P of length N.

We define SUM(k, i) as sum of the set of numbers {i, A[i], A[A[i]], A[A[A[i]]], … ,

Where 1 ≤ i ≤ N and A = P^{k}, 1 ≤ k ≤ N.


P^{1}[i] = P[i]
P^{2}[i] = P[P[i]]
P^{3}[i] = P[P[P[i]]]

Let S be the set containing SUM(k, i) for all 1 ≤ i ≤ N and 1 ≤ k ≤ N.

Print the elements of S in increasing order.

Note: A set contains no duplicate elements.

You might also like