title: c++ program to solve a problem
body: <p>I am  stuck with a c++ program which is an assignment.<br> Please help me out.
  Please suggest  an approach if possible,<br> <em>thanks in advance</em></p>
  
  <p>Problem:</p>
  
  <p>Given two vessels, one of which can accommodate <strong>a</strong> liters of water and the other which can 
  accommodate <strong>b</strong> liters of water, determine the number of steps required to obtain exactly  <strong>c</strong>
  liters of water in one of the vessels.</p>
  
  <p>At the beginning both vessels are empty. The following operations are counted as 'steps': </p>
  
  <ul>
  <li>emptying a vessel,  </li>
  <li>filling a vessel, </li>
  <li>pouring water from one vessel to the other, without spilling, until one of the vessels is 
  either full or empty.  </li>
  </ul>
  
  <p>Input</p>
  
  <p>An integer t, 1&lt;=t&lt;=100, denoting the number of test cases, followed by t sets of input data, 
  each consisting of three positive integers <strong>a</strong> (the number of liters the first container can hold), 
  <strong>b</strong> (the number of liters the second container can hold), and <strong>c</strong> (the final amount of liters of 
  water one vessel should contain), not larger than 40000, given in separate lines.</p>