CodeChef

[Solved] Maximise Sum C++, Java , Python

Maximise Sum

You are given an array A consisting of N positive integers. You are allowed to do the following operation any number of times: Find the maximum value of ∑i=1N​Ai​ that you can achieve after any (possibly zero) number of operations. Input Format Output Format For each test case,…

[Solved] Equal Hamming Distance CodeChef Starters 75

[Solved] Equal Hamming Distance CodeChef Starters 75

Chef is given two binary strings A and B, each having length N. Chef wants to find the number of binary strings �C, of length �N, such that �(�,�)=�(�,�)H(A,C)=H(B,C), where �(�,�)H(X,Y) denotes the hamming distance between the strings �X and �Y. Since the answer can be large, output it modulo 109+7109+7. Note: Hamming distance between two strings…

[Solved] Maximum of GCDs January Long 2023 CodeChef

[Solved] Maximum of GCDs January Long 2023 CodeChef

Maximum of GCDs: You are given an array A of N positive integers.The power of a subarray A[L,R] (1≤L≤R≤N) having size (R−L+1) is defined as gcd(AL​,A(L+1)​,…,AR​), where gcd⁡ denotes the greatest common divisor. Your task is to find the maximum power of a subarray of size k, for all 1≤k≤N. A subarray is formed by deleting some (possibly…

[Solved] Find an integer STARTERS 73 CodeChef

[Solved] Find an integer STARTERS 73 CodeChef

Chef has two nephews who love integers XX and YY. An integer NN is awesome if the following conditions hold: Find any awesome integer N. We can prove that under the given constraints, an answer always exists. Note that you do not have to minimize the answer. Input Format Output Format For…

[Solved] Consecutive Xor STARTERS 73 CodeChef

[Solved] Consecutive Xor STARTERS 73 CodeChef

Chef has an array AA of length NN. He can perform the following operation on AA: 1) Select an index ii (1 \le i \le N – 1)(1≤i≤N−1) and select an integer XX (1 \le X \lt 2^{20})(1≤X<220).\\2) Set A_i := (A_i \oplus X)Ai​:=(Ai​⊕X) and A_{i + 1} := (A_{i + 1} \oplus X)Ai+1​:=(Ai+1​⊕X).…

[Solved] Append for OR STARTERS 73 CodeChef

[Solved] Append for OR STARTERS 73 CodeChef

Chef has an array AA of length NN. Chef wants to append a non-negative integer XX to the array AA such that the bitwise OR of the entire array becomes = Y=Y i.e. (A_1 \ | \ A_2 \ | \ \ldots \ | \ A_N \ | \ X) = Y(A1​ ∣ A2​ ∣ … ∣ AN​ ∣ X)=Y. (Here, |∣ denotes the…

[Solved] Lucky Numbers STARTERS 73 CodeChef

[Solved] Lucky Numbers STARTERS 73 CodeChef

Chef calls a number lucky if it contains the digit 77 at least once. Given a number XX, determine if it is a lucky number or not. Input Format Output Format For each test case, output YES if XX is a lucky number. Otherwise, output NO. You may print each character of YES and NO in…