- #include<iostream>
- using namespace std;
- int main ()
- {
- int x , y;
- int testCases;
- int min_steps = 0;
- cin>>testCases;
- for(int i=0; i<testCases ; i++)
- {
- cin>>x>>y;
- int difference = y - x;
- min_steps = 0;
- if(difference != 0)
- {
- int sumOfSteps = 0;
- int z = 2; //divided by 2, it represents the size if the next step
- while(difference > sumOfSteps)
- {
- sumOfSteps += (z / 2); //next step
- min_steps++;
- z++;
- }
- }
- cout<<min_steps<<endl;
- }
- return 0;
- }
You can find more of my solutions on Here
8/11/2013
846 - Steps - UVA
8/01/2013
10079 - Pizza Cutting - UVA
- #include<iostream>
- using namespace std;
- int main ()
- {
- long long N , Max;
- while(true)
- {
- cin>>N;
- if(N<0)break;
- else{
- Max = N*(N+1)/2+1;
- cout<<Max<<endl;
- }
- }
- return 0;
- }
You can find more of my solutions on Here
11764 - Jumping Mario - UVA
- #include<iostream>
- using namespace std;
- int main ()
- {
- int arr[50];
- int testCases ;
- int N;
- cin>>testCases;
- for(int i=0; i<testCases ; i++){
- cin>>N;
- int ups = 0 , downs = 0; //counters
- for(int ii=1; ii<=N; ii++){
- cin>>arr[ii];
- }
- for(int j=1; j<N; j++){
- if(arr[j]<arr[j+1])
- ++ups;
- if(arr[j]>arr[j+1])
- ++downs;
- if(arr[j] == arr[j+1])
- continue;
- }
- cout<<"Case "<<i+1<<": "<<ups<<" "<<downs<<endl;
- }
- return 0;
- }
You can find more of my solutions on Here
Subscribe to:
Comments (Atom)