title: Check if an integer is GCD of some elements in a given set
body: <p>Given a set of positive integers and an integer <code>k</code>. <strong>All of the elements</strong> in the set is divisible by <code>k</code>.</p>
  
  <p>How to check if <code>k</code> is greatest common divisor of <strong>some</strong> elements in the set?</p>
  
  <p>My idea: For every element <code>a[i]</code> in the set, I divide it by <code>k</code>. Then I get GCD of all of the element in the set (which was changed after I divided). If the GCD is equal to 1, then <code>k</code> is GCD of some elements in the set.</p>
  
  <p>I have make some test cases and I see it right. But the online judge doesn't accept. Please give me an idea, or check my algorithm and fix it. Thank you very much.</p>
  
  <p>Let me speak it more clearly:</p>
  
  <p>For instance, a = {10, 15, 18}:</p>
  
  <p><code>k = 5</code> is GCD(10, 15). Answer is <code>true</code></p>
  
  <p><code>k = 3</code> is GCD(15, 18). Answer is <code>true</code></p>
  
  <p><code>k = 1</code> is GCD(10, 15, 18). Answer is <code>true</code></p>
  
  <p><code>k = 6</code> is not GCD of any group which contains more than 2 integers. Answer is <code>false</code> </p>
  
  <p>Size of the set: &lt;= 100000</p>
  
  <p>EDIT: Sorry for giving a wrong example. It was my mistake. <code>k = 3</code> is not GCD(10, 18). But I thought you might know this is <code>15</code> instead, right. :) Thanks for your answers, comments and contribution. I have voted an accepted answer below.</p>