8/11/2013

846 - Steps - UVA

  1. #include<iostream>
  2. using namespace std;
  3. int main ()
  4. {
  5.         int x , y;
  6.         int testCases;
  7.         int min_steps = 0;
  8.         cin>>testCases;
  9.        
  10.         for(int i=0; i<testCases ; i++)
  11.         {
  12.                 cin>>x>>y;
  13.                 int difference = y - x;
  14.                 min_steps = 0;
  15.                 if(difference != 0)
  16.                 {
  17.                          int sumOfSteps = 0;
  18.                       int z = 2; //divided by 2, it represents the size if the next step
  19.                         while(difference > sumOfSteps)
  20.                         {
  21.                                 sumOfSteps += (/ 2); //next step
  22.                                 min_steps++;
  23.                                 z++;
  24.                         }
  25.                 }
  26.                
  27.                 cout<<min_steps<<endl;
  28.         }
  29.         return 0;
  30. }


    You can find more of my solutions on
     Here

No comments:

Post a Comment