Codechef

Codechef long challenge problems

CodeChef: May Long Challenge | Modular Equation | MODEQ | Solution

Share:

Share:View on Codechef Given integers NN and MM, find the number of ordered pairs (a,b)(a,b) such that 1≤a<b≤N1≤a<b≤N and ((M mod a) mod b)=((M mod b) mod a)((M mod a) mod b)=((M mod b) mod a). Input The first line contains an integer TT, the number of test cases. Then the test cases follow. The only line of each test case contains two integers NN, MM. Output For each testcase, output in a single line the answer to the problem. Constraints 1≤T≤10001≤T≤1000 …

CodeChef: May Long Challenge | Modular Equation | MODEQ | Solution Read More »

Tic Tac Toe CodeChef Solution | Easy Approach | C++ Java Python

Share:

Share:Tic Tac Toe CodeChef Solution View on Codechef Tic-tac-toe is a game played between two players on a 3×33×3 grid. In a turn, a player chooses an empty cell and places their symbol on the cell. The players take alternating turns, where the player with the first turn uses the symbol XX and the other player uses the symbol OO. …

Tic Tac Toe CodeChef Solution | Easy Approach | C++ Java Python Read More »

Xor Equality CodeChef Solution | Easy Approach | C++, Java, Python

Share:

Share:Xor Equality CodeChef Solution Codechef For a given NN, find the number of ways to choose an integer xx from the range [0,2N−1][0,2N−1] such that x⊕(x+1)=(x+2)⊕(x+3)x⊕(x+1)=(x+2)⊕(x+3), where ⊕⊕ denotes the bitwise XOR operator. Since the number of valid xx can be large, output it modulo 109+7109+7. Input The first line contains an integer TT, the number of test cases. Then the test cases follow. The only line …

Xor Equality CodeChef Solution | Easy Approach | C++, Java, Python Read More »

CodeChef: May Long Challenge | Golf | LKDNGOLF | Solution

Share:

Share:View on Codechef It’s a lockdown. You’re bored in your house and are playing golf in the hallway. The hallway has N+2N+2 tiles numbered from 00 to N+1N+1 from left to right. There is a hole on tile number xx. You hit the ball standing on tile 00. When you hit the ball, it bounces at lengths of kk, i.e. the tiles covered by …

CodeChef: May Long Challenge | Golf | LKDNGOLF | Solution Read More »

Worthy Matrix CodeChef Solution | Easy Approach | C++, Java, Python

Share:

Share:Worthy Matrix CodeChef Solution View on Codechef Chef found a matrix AA with NN rows (numbered 11 through NN) and MM columns (numbered 11 through MM), where for each row rr and column cc, the cell in row rr and column cc (denoted by (r,c)(r,c)) contains an integer Ar,cAr,c. This matrix has two interesting properties: The integers in each row form a non-decreasing sequence, i.e. for each valid ii, Ai,1≤Ai,2≤…≤Ai,MAi,1≤Ai,2≤…≤Ai,M. The integers in each column also form a …

Worthy Matrix CodeChef Solution | Easy Approach | C++, Java, Python Read More »

CodeChef: April Long Challenge | Chef and Dice | SDICE | Solution

Share:

Share:View on Codechef Chef has NN 6-sided standard dice. Each die has dimensions 1×1×11×1×1. Since Chef is bored during the quarantine, he decides to stack dice for fun. First, Chef forms four vertical stacks of dice (not necessarily with the same height; empty stacks are allowed) on his table, which together make up a pile of dice with …

CodeChef: April Long Challenge | Chef and Dice | SDICE | Solution Read More »

CodeChef: April Long Challenge | Strong Language | SSCRIPT | Solution

Share:

Share:View on Codechef A string is said to be using strong language if it contains at least KK consecutive characters ‘*’. You are given a string SS with length NN. Determine whether it uses strong language or not. Input The first line of the input contains a single integer TT denoting the number of test cases. The description of TT test cases follows. The first line …

CodeChef: April Long Challenge | Strong Language | SSCRIPT | Solution Read More »

CodeChef: April Long Challenge | World Record |BOLT | Solution

Share:

Share:View on Codechef This news headline has been echoing in Chef’s mind since 2009 when he started his career in sprinting. This time in the 20212021 Tokyo Olympics he is determined to make a new world record. There are mainly 33 important factors that result in the variation in speed during practice and during competition. The first factor is a difference …

CodeChef: April Long Challenge | World Record |BOLT | Solution Read More »

Codechef: April Long Challenge | Valid Pair | SOCKS | Solution

Share:

Share:View on Codechef Chef has three socks in his drawer. Each sock has one of 1010 possible colors, which are represented by integers between 11 and 1010. Specifically, the colors of the socks are AA, BB, and CC. Chef has to wear two socks which have the same colour. Help Chef find out if that is possible or not. Input The first and …

Codechef: April Long Challenge | Valid Pair | SOCKS | Solution Read More »

x