3/17/2013

10783 Odd Sum - UVA


  1. #include<iostream>
  2. using namespace std;
  3. int main ()
  4. {
  5.         int testCases;
  6.         int a,b;
  7.        
  8.         cin>>testCases;
  9.         for(int i=0; i<testCases; i++)
  10.         {
  11.                 int sumOfOdd = 0;
  12.                 cin>>a>>b;
  13.                 for(int j=a; j<=b; j++)
  14.                 {
  15.                         if(j%2 !=0)
  16.                         {
  17.                                 sumOfOdd+=j;
  18.                         }
  19.                         else
  20.                         {
  21.                                 continue;
  22.                         }
  23.                 }
  24.                 cout<<"Case "<<i+1<<": "<<sumOfOdd<<endl;
  25.         }
  26.         return 0;
  27. }

You can find more of my solutions on Here

3/16/2013

10970 Big Chocolate - UVA


  1. #include<iostream>
  2. using namespace std;
  3. int main ()
  4. {
  5.         int m , n;
  6.         while(cin>>m>>n)
  7.         {
  8.                 int res = (m*n) - 1;
  9.                 cout<<res<<endl;
  10.         }
  11.         return 0;
  12. }

You can find more of my solutions on Here

11984 A Change in Thermal Unit - UVA


  1. #include<iostream>
  2. #include<iomanip>  //for setprecision()
  3. using namespace std;
  4. int main ()  
  5. {
  6.         int testCases ;
  7.         float cel , incInFahr ; //for celsuis , and the increse in fahrenheit
  8.         float fahrenheit;
  9.         cin>>testCases;
  10.         for(int i=0; i<testCases ; i++)
  11.         {
  12.                 cin>>cel>>incInFahr;
  13.                 fahrenheit = (((cel * 9)/5)+32 ) ;
  14.                 fahrenheit +=incInFahr;
  15.                 cel = ((fahrenheit - 32) * 5/9);
  16.                
  17.                 cout<<"Case "<<i+1<<": "<<fixed<<setprecision(2)<<cel<<endl;
  18.         }
  19.         return 0;
  20. }

You can find more of my solutions on Here

11547 Automatic Answer - UVA


  1. #include<iostream>
  2. using namespace std;
  3. int main ()
  4. {
  5.         int testCases;
  6.         int n; //for the number entered by the user
  7.        
  8.         cin>>testCases;
  9.         for(int i=0; i<testCases ; i++)
  10.         {
  11.                 cin>>n;
  12.                 int res = n*567; 
  13.                 res /=9;
  14.                 res +=7492;
  15.                 res *=235;
  16.                 res /=47;
  17.                 res -=498;
  18.                
  19.                
  20.                 res %=100;
  21.                 res /=10;
  22.                 if(res < 0)
  23.                 {
  24.                         res *=-1;
  25.                     cout<<res<<endl;
  26.                 }
  27.                 else
  28.                 {
  29.                         cout<<res<<endl;
  30.                 }
  31.         }
  32.         return 0;
  33. }

You can find more of my solutions on Here

11854 Egypt - UVA


  1. #include<iostream>
  2. using namespace std;
  3. int main ()
  4. {
  5.         int side1 , side2 , side3;
  6.         while(cin>>side1>>side2>>side3)
  7.         {
  8.                 if(side1==0 && side2==0 && side3==0){
  9.                         break;
  10.                 }
  11.                 else if(side1*side1 + side2*side2 == side3*side3 || side1*side1 + side3*side3 == side2*side2 ||side3*side3 +side2*side2 == side1*side1)
  12.                 {
  13.                         cout<<"right"<<endl;
  14.                 }
  15.                 else
  16.                 {
  17.                         cout<<"wrong"<<endl;
  18.                 }
  19.         }
  20.         return 0;
  21. }

You can find more of my solutions on Here

11727 Cost Cutting - UVA


  1. #include<iostream>
  2. using namespace std;
  3. int main ()
  4. {
  5.         int testCases;
  6.         int emp1 , emp2 , emp3; //for employee1 , employee2 , employee3
  7.        
  8.         cin>>testCases;
  9.         for(int i=0; i<testCases ; i++)
  10.         {
  11.                 cin>>emp1>>emp2>>emp3;
  12.                 if(emp2>emp1 && emp2<emp3 || emp2<emp1 && emp2>emp3)
  13.                 {
  14.                         cout<<"Case "<<i+1<<": "<<emp2<<endl;
  15.                 }
  16.                 else if(emp1>emp2 && emp1<emp3 || emp1<emp2 && emp1>emp3)
  17.                 {
  18.                         cout<<"Case "<<i+1<<": "<<emp1<<endl;
  19.                 }
  20.                 else
  21.                 {
  22.                         cout<<"Case "<<i+1<<": "<<emp3<<endl;
  23.                 }
  24.         }
  25.         return 0;
  26. }

You can find more of my solutions on Here

11172 Relational Operator - UVA


  1. #include<iostream>
  2. using namespace std;
  3. int main ()
  4. {
  5.         int testCases;
  6.         int num1 , num2;
  7.         cin>>testCases;
  8.        
  9.         for(int i=0; i<testCases ; i++)
  10.         {
  11.                 cin>>num1>>num2;
  12.                 if(num1 > num2){
  13.                         cout<<">"<<endl;
  14.                 }
  15.                 else if(num1 < num2){
  16.                         cout<<"<"<<endl;
  17.                 }
  18.                 else {
  19.                         cout<<"="<<endl;
  20.                 }
  21.         }
  22.         return 0;
  23. }

You can find more of my solutions on Here

10071 Back to High School Physics - UVA


  1. #include<iostream>
  2. using namespace std;
  3. int main ()
  4. {
  5.         int velocity , time;
  6.         while(cin>>velocity>>time)
  7.         {
  8.                 int displacement = 2*velocity*time;
  9.                 cout<<displacement<<endl;
  10.         }
  11.         return 0;
  12. }

You can find more of my solutions on Here