Showing posts with label URI 1 [Beginner]. Show all posts
Showing posts with label URI 1 [Beginner]. Show all posts

Saturday, December 28, 2013

1011 Sphere

URI Online Judge | 1011

Sphere

Adapted by Neilor Tonin, URI Brazil
Timelimit: 1
Make a program that calculates and print the volume of a sphere given the radius (R) of the circle. The formula to calculate the volume is: 4/3 * pi * R3. For the purposes of this problem the value of pi is 3.14159.

Input

The input file contain an integer number.

Output

The output file will contain a message like the following example. Remember the space before and after the equal signal. The value must be printed with 3 digits after the decimal point.
Sample Input Sample Output
3
VOLUME = 113.097
 
Solution:
#include <stdio.h>
int main(){
    register int R;
    scanf("%d", &R);
    printf("VOLUME = %.3f\n", 4.188786*R*R*R);
    return 0;
}

1005 Average 1


URI Online Judge | 1005

Average 1

Adapted by Neilor Tonin, URI Brazil
Timelimit: 1
Make a simple program that read two floating numbers corresponding to two tests for a student. After, calculate the average between them, considering that the first number has 3.5 weight and the second one have 7.5 weight. Each number can be from zero to ten, always with one digit after the decimal point. Don’t forget to print end line after the result otherwise you will get “Presentation Error”. Don’t forget the space before and after the equal sign.

Input

The input file will contain 2 floating-point numbers with one digit after the decimal point.

Output

Print MEDIA(average in portuguese) according to the following example, with 5 digits after the decimal point and a blank space before and after the equal signal.
Sample Input Sample Output
5.0
7.1
MEDIA = 6.43182

Solution:
#include <stdio.h>
int main(){
    float x,y;
    scanf("%f %f", &x, &y);
    printf("MEDIA = %.5f\n", (x*3.5+y*7.5)/(3.5+7.5));
    return 0;
}