CEQU - Crucial Equation

Let us see the following equation,


Given three positive integers a, b and c. You have to determine whether there exists at least one solution for some integers value of x and y where x, y may be negative or non-negative integers.

For example if a=2, b=4 and c=8 then the equation will be 2x+4y=8, and hence, for x=2 and y=1, there exists a solution.

Let us see another example for a=3, b=6 and c=7, so the equation will become 3x+6y=7 and there exists no solution satisfying this equation.


Input starts with an integer T (1<=T<=105) denoting the number of test cases. Each test case contains three integers a, b, and c. (1<=a, b, c<=106).


For each test case of input print the case number and “Yes” if there exists at least one solution, print “No” otherwise.

Sample Input

Output for Sample Input

2 4 8
3 6 7

Case 1: Yes
Case 2: No

Problem Setter: Md Abdul Alim, CEO and Founder at CodeMask

hide comments
stark_attack: 2017-02-18 19:33:57

space between : and Yes / No (*it cause me two WA)

code96maker: 2017-02-14 22:08:14

simple one for who knows diophantine equation...

ayushgupta1997: 2017-01-07 14:19:01

easy :) my 20th..got wa due to output format.Use Diophantine Equation...hope this helps:)

satya_jha123: 2016-12-02 15:43:08

Linear Diophantine Equations condition

spartax: 2016-11-26 05:11:31


cnexans: 2016-11-25 20:15:01

You don't have to just print "Yes" and "No". Literally, you gotta print
Case 1: ...
Case 2: ...

kushalanand: 2016-11-13 17:07:03

a=3 b=7 c=11 AC solution giving Yes. weird.

E Naveen Kumar: 2016-10-27 08:55:42

AC in a GO...!!

vaibhav goyal: 2016-08-17 15:36:04

Question is Just the condition of Simple Linear Diophantine Equation :P

heemansh: 2016-08-15 23:29:03

take care of \n ....get wa a lot..

Added by:Md Abdul Alim
Time limit:3s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64 GOSU
Resource:Own Problem