Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.


Limits 1s, 512 MB

Technology is going ahead very fast. How can we know what will we get in future? One day you met a guy suddenly in weird get up. He came to you and said a very strange thing. He said, "I have come from the year 2047!"

As you didn't believe him he took you to show his time machine. You were amazed to see his time machine. There were many switches in his machine. He described you the mechanism. If you choose a switch with value X you can either go X years forward or backward. Now he asked you a very interesting question. He asked you, "Can I visit any year using these switches as many times as I want?"

For clarity let's say he is now in the year A and wants to go in year B. He can go to as many intermediate years C as he needs. And from any intermediate year, he can use any switch of the time machine and can go forward or backward as he wishes.


The first line will contain the number of times you have to answer his question T (1 < T < 10).

In each case, there will be two lines. The first line will contain a number denoting the number of switches in his time machine N (1 < N < 100000).

The next line will contain N space separated integers denoting the value of each switch.

All values will be positive and less than or equal 100000.


Print ‘yes’ if he can travel every year using these switches otherwise ‘no’ without the quotation mark.


2 4



57% Solution Ratio

dmehrab06Earliest, Nov '17

rased_299Fastest, 0.0s

mls_sustLightest, 131 kB

Ultra.NazmulShortest, 215B


Login to submit

Toph uses cookies. By continuing you agree to our Cookie Policy.