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;
}

URI Online Judge Solution : 1014 Consumption (Beginner Problem)


URI Online Judge | 1014

Consumption

Adapted by Neilor Tonin, URI  Brazil
Timelimit: 1
Calculate a car's average consumption being provided the total distance traveled (in Km) and the spent fuel total (in liters).

Input

The input file contains two values: one integer value representing the total distance (in Km) and the second one is a floating point number Y  representing the spent fuel total, with a digit after the decimal point.

Output

Present a value that represents the average consumption of a car with 3 digits after the decimal point, followed by the message "km/l".
Input SampleOutput Sample
500
35.0
14.286 km/l
2254
124.4
18.119 km/l
4554
464.6
9.802 km/l

Solution


#include<stdio.h>


int main()
{
	int X;
	float Y;
	scanf("%d %f", &X, &Y);
	printf("%.3f km/l\n", X / Y);
	return 0;
}

URI Online Judge Solution : 1013 The Greatest (Beginner Problem)


URI Online Judge | 1013

The Greatest

Adapted by Neilor Tonin, URI  Brazil
Timelimit: 1
Make a program that reads 3 integer values and present the greatest one followed by the message "eh o maior". Use the following formula:

Input

The input file contains 3 integer values.

Output

Print the greatest of these three values followed by a space and the message “eh o maior”.
Input SamplesOutput Samples
7 14 106106 eh o maior
217 14 6217 eh o maior

Solution


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

int main()
{
	int A, B, C;
	int maiorAB,maiorAC,maiorBC;
	
	scanf("%d %d %d", &A, &B, &C);
	maiorAB = (A + B + abs(A - B)) / 2;
	maiorAC = (maiorAB + C + abs(maiorAB - C)) / 2;


	printf("%d eh o maior\n", maiorAC);
	return 0;
}

URI Online Judge Solution : 1012 Area (Beginner Problem)


URI Online Judge | 1012

Area

Adapted by Neilor Tonin, URI  Brazil
Timelimit: 1
Make a program that reads three floating point values: A, B and C. Then, calculate and show:
a) the area of the rectangled triangle that has base A and height C.
b) the area of the radius's circle C. (pi = 3.14159)
c) the area of the trapezium which has A and B by base, and C by height.
d) the area of ​​the square that has side B.
e) the area of the rectangle that has sides A and B.

Input

The input file contains three double values with one digit after the decimal point.

Output

The output file must contain 5 lines of data. Each line corresponds to one of the areas described above, always with a corresponding message (in Portuguese) and one space between the two points and the value. The value calculated must be presented with 3 digits after the decimal point.
Input SamplesOutput Samples
3.0 4.0 5.2TRIANGULO: 7.800
CIRCULO: 84.949
TRAPEZIO: 18.200
QUADRADO: 16.000
RETANGULO: 12.000
12.7 10.4 15.2TRIANGULO: 96.520
CIRCULO: 725.833
TRAPEZIO´: 175.560
QUADRADO: 108.160
RETANGULO: 132.080

Solution


#include<stdio.h>
#define PI 3.14159

int main()
{
	float A, B, C;

	scanf("%f %f %f", &A, &B, &C);
	printf("TRIANGULO: %.3f\n", 0.5*A*C);
	printf("CIRCULO: %.3f\n", PI*C*C);
	printf("TRAPEZIO: %.3f\n", ((A+B)/2)*C);
	printf("QUADRADO: %.3f\n", B*B);
	printf("RETANGULO: %.3f\n", A*B);

	return 0;
}

URI Online Judge Solution : 1011 Sphere (Beginner Problem)


URI Online Judge | 1011

Sphere

Adapted by Neilor Tonin, URI  Brazil
Timelimit: 1
Make a program that calculates and shows the volume of a sphere being provided the value of its radius (R) . The formula to calculate the volume is: (4/3) * pi * R3. Consider (assign) for pi the value 3.14159.
Tip: Use (4/3.0) or (4.0/3) in your formula, because some languages (including C++) assume that the division's result between two integers is another integer. :)

Input

The input contains a value of floating point (double precision).

Output

The output must be a message "VOLUME" like the following example with a space before and after the equal signal. The value must be presented with 3 digits after the decimal point.
Input SamplesOutput Samples
3VOLUME = 113.097
15VOLUME = 14137.155
1523VOLUME = 14797486501.627

Solution


#include<stdio.h>
#define PI 3.14159

int main()
{
	double R,Vol;
	scanf("%lf", &R);
	Vol = (4.0 / 3.0)*PI*R*R*R;
	printf("VOLUME = %.3lf\n", Vol);
	return 0;
}

URI Online Judge Solution : 1010 Simple Calculate (Beginner Problem)

URI Online Judge | 1010

Simple Calculate

Adapted by Neilor Tonin, URI  Brazil
Timelimit: 1
In this problem, the task is to read a code of a product 1, the number of units of product 1, the price for one unit of product 1, the code of a product 2, the number of units of product 2 and the price for one unit of product 2. After this, calculate and show the amount to be paid.

Input

The input file contains two lines of data.\ In each line there will be 3 values: two integers and a floating value with 2 digits after the decimal point.

Output

The output file must be a message like the following example where "Valor a pagar" means Value to Pay. Remember the space after ":" and after "$" symbol. The value must be presented with 2 digits after the point.
Input SamplesOutput Samples
12 1 5.30
16 2 5.10
VALOR A PAGAR: R$ 15.50
13 2 15.30
161 4 5.20
VALOR A PAGAR: R$ 51.40
1 1 15.10
2 1 15.10
VALOR A PAGAR: R$ 30.20

Solution


#include<stdio.h>


int main()
{
	int p1, p1_u, p2, p2_u;
	float p1_price, p2_price;
	float payment;
	
	scanf("%d %d %f %d %d %f", &p1, &p1_u, &p1_price, &p2, &p2_u, &p2_price);
	
	payment = p1_price*p1_u + p2_price*p2_u;

	printf("VALOR A PAGAR: R$ %.2f\n", payment);


	return 0;
}

URI Online Judge Solution : 1009 Salary with Bonus (Beginner Problem)


URI Online Judge | 1009

Salary with Bonus

Adapted by Neilor Tonin, URI  Brazil
Timelimit: 1
Make a program that reads a seller's name, his/her fixed salary and the sale's total made by himself/herself in the month (in money). Considering that this seller receives 15% over all products sold, write the final salary (total) of this seller at the end of the month , with two decimal places.
- Don’t forget to print the line's end after the result, otherwise you will receive “Presentation Error”.
- Don’t forget the blank spaces.

Input

The input file contains a text (employee's first name), and two double precision values, that are the seller's salary and the total value sold by him/her.

Output

Print the seller's total salary, according to the given example.
Input SamplesOutput Samples
JOAO
500.00
1230.30
TOTAL = R$ 684.54
PEDRO
700.00
0.00
TOTAL = R$ 700.00
MANGOJATA
1700.00
1230.50
TOTAL = R$ 1884.58

Solution


#include<stdio.h>


int main()
{
 char name[15];
 double salary, amount;
 double bonus;
 scanf("%s", &name);
 scanf("%lf %lf", &salary, &amount);
 bonus = (amount * 15) / 100;
 salary = salary + bonus;
 printf("TOTAL = R$ %.2lf\n", salary);


 return 0;
}

URI Online Judge Solution : 1008 Salary (Beginner Problem)

URI Online Judge | 1008

Salary

Adapted by Neilor Tonin, URI  Brazil
Timelimit: 1
Write a program that reads an employee's number, his/her worked hours number in a month and the amount he received per hour. Print the employee's number and salary that he/she will receive at end of the month, with two decimal places.
  • Don’t forget to print the line's end after the result, otherwise you will receive “Presentation Error”.
  • Don’t forget the space before and after the equal signal and after the U$.

Input

The input file contains 2 integer numbers and 1 value of floating point, representing the number, worked hours amount and the amount the employee receives per worked hour.

Output

Print the number and the employee's salary, according to the given example, with a blank space before and after the equal signal.
Input SamplesOutput Samples
25
100
5.50
NUMBER = 25
SALARY = U$ 550.00
1
200
20.50
NUMBER = 1
SALARY = U$ 4100.00
6
145
15.55
NUMBER = 6
SALARY = U$ 2254.75

Solution


#include<stdio.h>


int main()
{
 int Number, Hours;
 float Rate,Salary;
 scanf("%d %d %f", &Number, &Hours,&Rate);
 
 Salary = Rate*Hours;
 printf("NUMBER = %d\n", Number);
 printf("SALARY = U$ %.2f\n", Salary);
 return 0;
}

URI Online Judge Solution : 1007 Difference (Beginner Problem)

URI Online Judge | 1007

Difference

Adapted by Neilor Tonin, URI  Brazil
Timelimit: 1
Read four integer values named A, B, C and D. Calculate and print the difference of product A and B by the product of C and D (A * B - C * D).

Input

The input file contains 4 integer values.

Output

Print DIFERENCA (DIFFERENCE in Portuguese) with all the capital letters, according to the following example, with a blank space before and after the equal signal.
Input SamplesOutput Samples
5
6
7
8
DIFERENCA = -26
0
0
7
8
DIFERENCA = -56
5
6
-7
8
DIFERENCA = 86

Solution


#include<stdio.h>


int main()
{
 int A, B, C, D, Differ;
 scanf("%d %d %d %d", &A, &B, &C, &D);
 Differ = (A*B - C*D);
 printf("DIFERENCA = %d\n", Differ);

 return 0;
}