# CodeChef: May Long Challenge | Golf | LKDNGOLF | Solution

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 it are 0,k,2k,…0,k,2k,…, and so on until the ball passes tile N+1N+1.

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

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 TT, the number of test cases. Then the test cases follow.
• The only line of each test case contains three integers N,x,kN,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

• 1≤T≤1051≤T≤105
• 1≤x,k≤N≤1091≤x,k≤N≤109

Subtask #2 (90 points): original constraints

### Sample Input

``````3
5 4 2
5 3 2
5 5 2
``````

### Sample Output

``````YES
NO
NO
``````

### Explanation

In each test case, the tiles covered by the ball for N=5N=5 and k=2k=2 are {0,2,4,6}{0,2,4,6} in the forward journey and {6,4,2,0}{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 44. But the answer for test cases 22 and 33 is “NO” since the ball does not fall in the position of the hole.

``Solution will be updated here soon. Keep tracking``
{"ft_lang_label":"__label__en","ft_lang_prob":0.84819204,"math_prob":0.9370308,"size":2021,"snap":"2022-27-2022-33","text_gpt3_token_len":628,"char_repetition_ratio":0.1328706,"word_repetition_ratio":0.10555556,"special_character_ratio":0.30479962,"punctuation_ratio":0.14512922,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9568599,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2022-08-19T18:01:08Z\",\"WARC-Record-ID\":\"<urn:uuid:7dd95efb-687a-48c6-ac4f-91ff68686956>\",\"Content-Length\":\"123958\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:17be42f2-65d4-474c-9b04-f0e43e55f1d0>\",\"WARC-Concurrent-To\":\"<urn:uuid:17ed29ff-494f-4309-afed-4bce4384f8ab>\",\"WARC-IP-Address\":\"104.21.84.198\",\"WARC-Target-URI\":\"https://thunderbitz.com/codechef-may-long-challenge-golf-lkdngolf-solution/\",\"WARC-Payload-Digest\":\"sha1:MSM463SSYWWOWPJVK3CL7BNPITNRZ3X4\",\"WARC-Block-Digest\":\"sha1:ULUKGM7D6N253AGCGQVH32TMK5THRF5B\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2022/CC-MAIN-2022-33/CC-MAIN-2022-33_segments_1659882573744.90_warc_CC-MAIN-20220819161440-20220819191440-00043.warc.gz\"}"}