Wednesday, November 02, 2016

Monday, July 04, 2016

URI Online Judge Solution : 1016 Distance (Beginner Problem)




URI Online Judge | 1016

Distance

Adapted by Neilor Tonin, URI  Brazil
Timelimit: 1
Two cars (X and Y) leave in the same direction. The car X leaves with a constant speed of 60 km/h and the car Y leaves with a constant speed of 90 km / h.
In one hour (60 minutes) the car Y can get a distance of 30 kilometers from the X car, in other words, it can get away one kilometer for each 2 minutes.
Read the distance (in km) and calculate how long it takes (in minutes) for the car Y to take this distance in relation to the other car.

Input

The input file contains 1 integer value.

Output

Print the necessary time followed by the message " minutos" that means minutes in Portuguese.
Input SampleOutput Sample
3060 minutos
110220 minutos
714 minutos

Solution


#include <stdio.h>
#include <math.h>

int main()
{
 int A;
 scanf("%d", &A);
 printf("%d minutos\n", 2 * A);
 return 0;
}

URI Online Judge Solution : 1015 Distance Between Two Points (Beginner Problem)


\
URI Online Judge | 1015

Distance Between Two Points

Adapted by Neilor Tonin, URI  Brazil
Timelimit: 1
Read the four values corresponding to the x and y axes of two points in the plane, p1 (x1, y1) and p2 (x2, y2) and calculate the distance between them, showing four decimal places after the comma, according to the formula:
Distance = 

Input

The input file contains two lines of data. The first one contains two double values: x1 y1 and the second one also contains two double values with one digit after the decimal point: x2 y2.

Output

Calculate and print the distance value using the provided formula, with 4 digits after the decimal point.
Input SampleOutput Sample
1.0 7.0
5.0 9.0
4.4721
-2.5 0.4
12.1 7.3
16.1484
2.5 -0.4
-12.2 7.0
16.4575

Solution

#include <stdio.h>
#include <math.h>

int main()
{
	double x1, x2, y1, y2;
	double distance;
	scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
	distance = sqrt(((x2 - x1)*(x2 - x1)) + ((y2 - y1)*(y2 - y1)));
	printf("%.4lf\n", distance);
	return 0;
}