Skip to main content

Golf | LKDNGOLF | May Challenge 2021 Division 2 & 3 | Codechef Solution | Latest Video Solution code

 

It's a lockdown. You’re bored in your house and are playing golf in the hallway.

The hallway has N+2 tiles numbered from 0 to N+1 from left to right. There is a hole on tile number x. You hit the ball standing on tile 0. When you hit the ball, it bounces at lengths of k, i.e. the tiles covered by it are 0,k,2k,, and so on until the ball passes tile N+1.

If the ball doesn't enter the hole in the first trial, you try again but this time standing on the tile N+1. When you hit the ball, it bounces at lengths of k, i.e. the tiles covered by it are (N+1),(N+1k),(N+12k),, and so on until the ball passes tile 0.

Find if the ball will enter the hole, either in its forward journey or backward journey.

Note: The input and output of this problem are large, so prefer using fast input/output methods.

Input

  • The first line contains an integer T, the number of test cases. Then the test cases follow.
  • The only line of each test case contains three integers N,x,k.

Output

Output in a single line, the answer, which should be "YES" if the ball enters the hole either in the forward or backward journey and "NO" if not.

You may print each character of the string in uppercase or lowercase (for example, the strings "yEs", "yes", "Yes" and "YES" will all be treated as identical).

Constraints

  • 1T105
  • 1x,kN109

Subtasks

Subtask #1 (10 points): N102

Subtask #2 (90 points): original constraints

Sample Input

3
5 4 2
5 3 2
5 5 2

Sample Output

YES
NO
NO
For Solution
Golf | LKDNGOLF | May Challenge 2021 Division 2 & 3 | Codechef Solution | Latest Video Solution code

Fullfill the Given Condition, and DM the Screenshot on Telegram or Instagram, We will provide the Code there, we are not Charging any kind of Money, so Keep in Mind. Don't Give Money to Anyone

Follow All :- 

SUBSCRIBE The Youtube Channel and Press the Bell Icon
Website :- https://codedelhi.blogspot.com
Telegram  :- https://t.me/EngineerDelhi
Facebook :- https://www.facebook.com/EngineerDelhi
Instagram :- https://www.instagram.com/engineerdelhi

Explanation

In each test case, the tiles covered by the ball for N=5 and k=2 are {0,2,4,6} in the forward journey and {6,4,2,0} in the backward journey.

Therefore, the answer for the first test case is "YES" since the ball falls in the position of the hole at tile 4. But the answer for test cases 2 and 3 is "NO" since the ball does not fall in the position of the hole.


Popular posts from this blog

BCA 5th and 6th Semester Project | BCSP-064 | Synopsys and Project | Both | IGNOU BCA | 100% Accepted | July 2023 and Jan 2024

 Synopsys and Project | Both | July 2023 and Jan 2024 Title of the Project : - PRODUCT HUB Buy it from here (Synopsis + Project) : Synopsis Content :- Synopsis : An overview of the entire project, summarizing its main objectives, scope, and outcomes. Introduction : Introduce the project and provide context for the reader by explaining the problem or need that the project aims to address. Aim and Objective : Clearly state the goals and objectives of the project, outlining what you intend to achieve through its completion. Project Category : Define the domain or category to which the project belongs, helping readers understand the context and purpose of the project. Tools and Platform : List the software tools, programming languages, and platforms you'll be using to develop and implement the project. System Analysis : Discuss the preliminary analysis phase of the project, where you identify requirements,

Flowchart and Pseudocode to Find the Area of a Square

  Write a flowchart and pseudocode to find the area of a square. Pseudocode :-  1. Start 2. Input length of the square 3. Calculate area of square as length * length 4. Print area 5. End #C++Programming Language #codeDelhi

MCS-021 | Data and File Structures | IGNOU BCA Solved Assignment | July 2021 & January 2022

  Course Code :- MCS-021 Course Title :- Data and File Structures Assignment Number :- BCA(3)/021/Assignment/2021-22 Maximum Marks :-  100 Weightage :-   25% Last Dates for Submission :- 31st October, 2021 (For July Session) &  15th April, 2022 (For January Session)  This assignment has four questions which carry 80 marks. Answer all the questions. Each question carries 20 marks. You may use illustrations and diagrams to enhance the explanations. Please go through the guidelines regarding assignments given in the Programme Guide. All the implementations should be in C programming language. Question 1: Write an algorithm that accepts a Binary Tree as inputs and outputs the traversals of Inorder , Postorder and Preorder of it. Question 2: Is it possible to implement multiple queues in a Stack. Justify your answer.  Question 3: List the names of all Sorting Algorithms along with their Complexities (Best case, Average case and Worst case). List as many names as possible along