Saturday, April 30, 2016

URI Online Judge Solution 1060 in Java || Positive Numbers

Main link:  https://www.urionlinejudge.com.br/judge/en/problems/view/1060

URI Online Judge | 1060

Positive Numbers

Adapted by Neilor Tonin, URI  Brazil
Timelimit: 1
Write a program that reads 6 numbers. These numbers will only be positive or negative (disregard null values). Print the total number of positive numbers.

Input

Six numbers, positive and/or negative.

Output

Print a message with the total number of positive numbers.
Input SampleOutput Sample
7
-5
6
-3.4
4.6
12
4 valores positivos


URI Online Judge Solution 1060 || Positive Numbers


import java.io.IOException;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws IOException {
    double X;
int totalPositive = 0;
Scanner input =new Scanner(System.in);
for (int i = 0; i < 6; i++) {
X = input.nextDouble();
if (X > 0) {
totalPositive += 1;
}
}
System.out.print(totalPositive+" valores positivos\n");

    }

}


Read More

URI Online Judge Solution 1059 in C language || Even Numbers

Main link: https://www.urionlinejudge.com.br/judge/en/problems/view/1059
URI Online Judge | 1059

Even Numbers

Adapted by Neilor Tonin, URI  Brazil
Timelimit: 1
Write a program that prints all even numbers between 1 and 100, including them if it is the case.

Input

In this extremely simple problem there is no input.

Output

Print all even numbers between 1 and 100, including them, one by row.
Input SampleOutput Sample
2
4
6
...
100


URI Online Judge Solution 1059 in C language || Even Numbers

#include<stdio.h>
int main()
{
int n = 100,i;
for( i =2; i <= n; i=i+2)
{
printf("%d\n", i);
}
return 0;
}


Read More

URI Online Judge Solution 1050 in C language || DDD


URI Online Judge | 1050

DDD

Adapted by Neilor Tonin, URI  Brazil
Timelimit: 1
Read an integer number that is the code number for phone dialing. Then, print the destination according to the following table:

If the input number isn’t found in the above table, the output must be:
DDD não cadastrado
That means “DDD not found” in Portuguese language.

Input

The input consists in a unique integer number.

Output

Print the city name corresponding to the input DDD. Print DDD nao cadastrado if doesn't exist corresponding DDD to the typed number.
Input SampleOutput Sample
11Sao Paulo

URI Online Judge Solution 1050 in C language || DDD


#include<stdio.h>
int main()
{
int n;
scanf("%d", &n);
if( n ==61 ){
printf("Brasilia\n");
}
else if( n ==71 ){
printf("Salvador\n");
}
else if( n ==11 ){
printf("Sao Paulo\n");
}
else if( n ==21 ){
printf("Rio de Janeiro\n");
}
else if( n ==32 ){
printf("Juiz de Fora\n");
}
else if( n ==19 ){
printf("Campinas\n");
}
else if( n ==27 ){
printf("Vitoria\n");
}
else if( n ==31 ){
printf("Belo Horizonte\n");
}
else {
printf("DDD nao cadastrado\n");
}
return 0;
}




Read More

URI Online Judge Solution 1052 in Java language || Month



URI Online Judge | 1052

Month

Adapted by Neilor Tonin, URI  Brazil
Timelimit: 1
Read an integer number between 1 and 12, including. Corresponding to this number, you must print the month of the year, in english, with the first letter in uppercase.

Input

The input contains only an integer number.

Output

Print the name of the month according to the input number, with the first letter in uppercase.
Input SampleOutput Sample
4April



URI Online Judge Solution 1052 in Java language || Month

import java.io.IOException;
import java.util.Scanner;


public class Main {

    public static void main(String[] args) throws IOException {

        
int N;
Scanner input =new Scanner(System.in);
switch (N =input.nextInt()) {
case 1:
System.out.print("January\n");
break;
case 2:
System.out.print("February\n");
break;
case 3:
System.out.print("March\n");
break;
case 4:
System.out.print("April\n");
break;
case 5:
System.out.print("May\n");
break;
case 6:
System.out.print("June\n");
break;
case 7:
System.out.print("July\n");
break;
case 8:
System.out.print("August\n");
break;
case 9:
System.out.print("September\n");
break;
case 10:
System.out.print("October\n");
break;
case 11:
System.out.print("November\n");
break;
case 12:
System.out.print("December\n");
break;

default:
break;
}


    }

}



Read More

URI Online Judge Solution 1051 in Java || Taxes


URI Online Judge | 1051

Taxes

By Neilor Tonin, URI  Brazil
Timelimit: 1
In an imaginary country called Lisarb, all the people are very happy to pay their taxes because they know that doesn’t exist corrupt politicians and the taxes are used to benefit the population, without any misappropriation. The currency of this country is Rombus, whose symbol is R$.
Read a value with 2 digits after the decimal point, equivalent to the salary of a Lisarb inhabitant. Then print the due value that this person must pay of taxes, according to the table below.


Remember, if the salary is R$ 3,002.00 for example, the rate of 8% is only over R$ 1,000.00, because the salary from R$ 0.00 to R$ 2,000.00 is tax free. In the follow example, the total rate is 8% over R$ 1000.00 + 18% over R$ 2.00, resulting in R$ 80.36 at all. The answer must be printed with 2 digits after the decimal point.

Input

The input contains only a float-point number, with 2 digits after the decimal point.

Output

Print the message "R$" followed by a blank space and the total tax to be payed, with two digits after the decimal point. If the value is up to 2000, print the message "Isento".
Input SamplesOutputs Samples
3002.00R$ 80.36
1701.12Isento
4520.00R$ 355.60

URI Online Judge Solution 1051 in Java || Taxes


import java.io.IOException;
import java.util.Scanner;

/**
 * IMPORTANT: 
 *      O nome da classe deve ser "Main" para que a sua solução execute
 *      Class name must be "Main" for your solution to execute
 *      El nombre de la clase debe ser "Main" para que su solución ejecutar
 */
public class Main {

    public static void main(String[] args) throws IOException {

        float n, r, f1, f2, f3;
Scanner sc =new Scanner(System.in);
n = sc.nextFloat();

if(n <= 2000){
System.out.print("Isento\n");
}else{
if(n > 2000 && n <= 3000){
f1 = n - 2000;
f1 = ((f1 * 8) / 100);
r = f1;
}else if(n > 3000 && n <= 4500){
f1 = n - 2000;
f2 = f1 - 1000;
f1 -= f2;
f1 = ((f1 * 8) / 100);
f2 = ((f2 * 18) / 100);
r = f2 + f1;
}else{
f1 = n - 2000;
f2 = f1 - 1000;
f3 = f2 - 1500;
f1 -= f2;
f2 -= f3;
f1 = ((f1 * 8) / 100);
f2 = ((f2 * 18) / 100);
f3 = ((f3 * 28) / 100);
r = f3 + f2 + f1;
}
System.out.printf("R$ %.2f\n",r);
}

    }

}



Read More

URI Online Judge Solution 1048 in Java language || Salary Increase




URI Online Judge | 1048

Salary Increase

By Neilor Tonin, URI  Brazil
Timelimit: 1
The company ABC decided to give a salary increase to its employees, according to the following table:


Read the employee's salary, calculate and print the new employee's salary, as well the money earned and the increase percentual obtained by the employee, with corresponding messages in Portuguese, as the below example.

Input

The input contains only a floating-point number, with 2 digits after the decimal point.

Output

Print 3 messages followed by the corresponding numbers (see example) informing the new salary, the among of money earned and the percentual obtained by the employee. Note:
Novo salario:  means "New Salary"
Reajuste ganho: means "Money earned"
Em percentual: means "In percentage"
Input SampleOutput Sample
400.00Novo salario: 460.00
Reajuste ganho: 60.00
Em percentual: 15 %
800.01Novo salario: 880.01
Reajuste ganho: 80.00
Em percentual: 10 %
2000.00Novo salario: 2140.00
Reajuste ganho: 140.00
Em percentual: 7 %


URI Online Judge Solution 1048 in Java language || Salary Increase

import java.io.IOException;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws IOException {

        float N,new_salary = 0,earn_Money = 0;
int parcent = 0;
Scanner input =new Scanner(System.in);
N =input.nextFloat();

if (N >= 0 && N <= 400.00) {
parcent = 15;
new_salary = (float) (N + (N * (parcent /100.00)));
earn_Money = (float) ((N * (parcent /100.00)));

}else if (N >= 400.01 && N <= 800.00) {
parcent = 12;
new_salary = (float) (N + (N * (parcent /100.00)));
earn_Money = (float) ((N * (parcent /100.00)));
}else if (N >= 800.01 && N <= 1200.00) {
parcent = 10;
new_salary = (float) (N + (N * (parcent /100.00)));
earn_Money = (float) ((N * (parcent /100.00)));

}else if (N >= 1200.01 && N <= 2000.00) {
parcent = 7;
new_salary = (float) (N + (N * (parcent /100.00)));
earn_Money = (float) ((N * (parcent /100.00)));
}else if (N >= 2000.01) {
parcent = 4;
new_salary = (float) (N + (N * (parcent /100.00)));
earn_Money = (float) ((N * (parcent /100.00)));
}

System.out.printf("Novo salario: %.2f\n",new_salary);
System.out.printf("Reajuste ganho: %.2f\n",earn_Money);
System.out.print("Em percentual: "+parcent+" %\n");


    }

}



Read More

URI 1047 Solution in C language



URI Online Judge | 1047

Game Time with Minutes

Adapted by Neilor Tonin, URI  Brazil
Timelimit: 1
Read the start time and end time of a game, in hours and minutes (initial hour, initial minute, final hour, final minute). Then print the duration of the game, knowing that the game can begin in a day and finish in another day,
Obs.: With a maximum game time of 24 hours and the minimum game time of 1 minute.

Input

Four integer numbers representing the start and end time of the game.

Output

Print the duration of the game in hours and minutes, in this format: “O JOGO DUROU XXX HORA(S) E YYY MINUTO(S)” . Which means: the game lasted XXX hour(s) and YYY minutes.
Input SampleOutput Sample
7 8 9 10O JOGO DUROU 2 HORA(S) E 2 MINUTO(S)
7 7 7 7O JOGO DUROU 24 HORA(S) E 0 MINUTO(S)
7 10 8 9O JOGO DUROU 0 HORA(S) E 59 MINUTO(S)

URI 1047 Solution in C language


#include <stdio.h>
int main()
{
    int start_h, end_h, start_m, end_m, duration_h, duration_m;
    scanf("%d %d %d %d", &start_h, &start_m, &end_h, &end_m);

    duration_h = end_h - start_h;

    if (duration_h < 0)
    {
        duration_h = 24 + (end_h - start_h);
    }

duration_m = end_m - start_m;
if (duration_m < 0)

{
 duration_m = 60 + (end_m - start_m);
 duration_h--;
}

    if (start_h == end_h && start_m == end_m)

    {
        printf("O JOGO DUROU 24 HORA(S) E 0 MINUTO(S)\n");
    }
    else printf("O JOGO DUROU %d HORA(S) E %d MINUTO(S)\n", duration_h, duration_m);
    return 0;
}

Read More

URI 1044 Solution in C Java language || Multiples




URI Online Judge | 1044

Multiples

Adapted by Neilor Tonin, URI  Brazil
Timelimit: 1
Read two nteger values (A and B). After, the program should print the message "Sao Multiplos" (are multiples) or "Nao sao Multiplos" (aren’t multiples), corresponding to the read values.

Input

The input has two integer numbers.

Output

Print the relative message to the input as stated above.
Input SampleOutput Sample
6 24Sao Multiplos
6 25Nao sao Multiplos

URI 1044 Solution in Java language || Triangle Types

import java.io.IOException;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws IOException {

        int A, B;
Scanner input =new Scanner(System.in);
A = input.nextInt();
B = input.nextInt();
if (B % A == 0 || A % B == 0) {
System.out.print("Sao Multiplos\n");
}else {
System.out.print("Nao sao Multiplos\n");
}

    }

}

URI 1044 Solution in C language || Triangle Types



#include<stdio.h>

    int main(){

        int A, B;
scanf("%d%d", &A,&B);
if (B % A == 0 || A % B == 0) {
printf("Sao Multiplos\n");
}else {
printf("Nao sao Multiplos\n");
}

    }



Read More

URI 1049 Solution in Java language || Animal



URI Online Judge | 1049

Animal

By Neilor Tonin, URI  Brazil
Timelimit: 1
In this problem, your job is to read three Portuguese words. These words define an animal according to the table below, from left to right. After, print the chosen animal defined by these three words.

Input

The input contains 3 words, one by line, that will be used to identify the animal, according to the above table, with all letters in lowercase.

Output

Print the animal name according to the given input.
Input SamplesOutput Samples
vertebrado
mamifero
onivoro
homem
vertebrado
ave
carnivoro
aguia
invertebrado
anelideo
onivoro
minhoca


URI 1049 Solution in Java language || Animal

import java.io.IOException;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws IOException {

        String A, B, C;
Scanner input =new Scanner(System.in);
A = input.next();
B = input.next();
C = input.next();

if (A.equals("vertebrado")  && B.equals("ave") && C.equals("carnivoro")) {
System.out.print("aguia\n");
}
if (A.equals("vertebrado") && B.equals("ave") && C.equals("onivoro")) {
System.out.print("pomba\n");
}
if (A.equals("vertebrado") && B.equals("mamifero") && C.equals("onivoro")) {
System.out.print("homem\n");
}
if (A.equals("vertebrado") && B.equals("mamifero") && C.equals("herbivoro")) {
System.out.print("vaca\n");
}
//-----------------------------------------------------------------

if (A.equals("invertebrado") && B.equals("inseto") && C.equals("hematofago")) {
System.out.print("pulga\n");
}
if (A.equals("invertebrado") && B.equals("inseto") && C.equals("herbivoro")) {
System.out.print("lagarta\n");
}
if (A.equals("invertebrado") && B.equals("anelideo") && C.equals("hematofago")) {
System.out.print("sanguessuga\n");
}
if (A.equals("invertebrado") && B.equals("anelideo") && C.equals("onivoro")) {
System.out.print("minhoca\n");
}

    }

}
Read More

URI Solution 1045 in Java language




URI Online Judge | 1045

Triangle Types

Adapted by Neilor Tonin, URI  Brazil
Timelimit: 1
Read 3 double numbers (A, B and C) representing the sides of a triangle and arrange them in decreasing order, so that the side A is the biggest of the three sides. Next, determine the type of triangle that they can make, based on the following cases always writing an appropriate message:
  • if A ≥ B + C, write the message: NAO FORMA TRIANGULO
  • if A2 = B2 + C2, write the message: TRIANGULO RETANGULO
  • if A2 > B2 + C2, write the message: TRIANGULO OBTUSANGULO
  • if A2 < B2 + C2, write the message: TRIANGULO ACUTANGULO
  • if the three sides are the same size, write the message: TRIANGULO EQUILATERO
  • if only two sides are the same and the third one is different, write the message: TRIANGULO ISOSCELES

Input

The input contains three double numbers, A (0 < A) , B (0 < B) and C (0 < C).

Output

Print all the classifications of the triangle presented in the input.
Input SamplesOutput Samples
7.0 5.0 7.0TRIANGULO ACUTANGULO
TRIANGULO ISOSCELES
6.0 6.0 10.0TRIANGULO OBTUSANGULO
TRIANGULO ISOSCELES
6.0 6.0 6.0TRIANGULO ACUTANGULO
TRIANGULO EQUILATERO
5.0 7.0 2.0NAO FORMA TRIANGULO
6.0 8.0 10.0TRIANGULO RETANGULO

URI Solution 1045 in Java language


import java.util.Scanner;

public class URI_1045 {

public static void main(String[] args) {
double A, B, C;
Scanner input =new Scanner(System.in);
A = input.nextDouble();
B = input.nextDouble();
C = input.nextDouble();
double tempA = Math.max(A, Math.max(B, C));
double tempB = 0;
double tempC = 0;

if (tempA == A) {
tempB =Math.max(B, C);
tempC =Math.min(B, C);
}
if (tempA == B) {
tempB =Math.max(A, C);
tempC =Math.min(A, C);
}
if (tempA == C) {
tempB =Math.max(B, A);
tempC =Math.min(B, A);
}
//------------------------------
if (tempA >= (tempB + tempC)) {
System.out.print("NAO FORMA TRIANGULO\n");

}else if (tempA*tempA > ((tempB*tempB)+(tempC*tempC))) {
System.out.print("TRIANGULO OBTUSANGULO\n");
}
if (tempA*tempA == ((tempB*tempB)+(tempC*tempC))) {
System.out.print("TRIANGULO RETANGULO\n");
}

if (tempA*tempA < ((tempB*tempB)+(tempC*tempC))) {
System.out.print("TRIANGULO ACUTANGULO\n");
}
if ((tempA == tempB) &&(tempA == tempC)) {
System.out.print("TRIANGULO EQUILATERO\n");
}
if (((tempA == tempB) &&(tempA != tempC)) || ((tempA == tempC) &&(tempA != tempB)) || ((tempB == tempC) &&(tempB != tempA)) ) {
System.out.print("TRIANGULO ISOSCELES\n");
}
}

}




Read More

URI Online Judge Solution 1042 in C C++ and Java language || Simple Sort




URI Online Judge | 1042

Simple Sort

Adapted by Neilor Tonin, URI  Brazil
Timelimit: 1
Read three integers and sort them in ascending order. After, print these values in ascending order, a blank line and then the values in the sequence as they were readed.

Input

The input contains three integer numbers.

Output

Present the output as requested above.
Input SampleOutput Sample
7 21 -14-14
7
21

7
21
-14
-14 21 7-14
7
21

-14
21
7

URI 1042 Solution in Java Language


import java.util.Scanner;
public class URI_1042 {
public static void main(String[] args) {
int X, Y, Z, min1, min2 = 0, min3 = 0;
Scanner input = new Scanner(System.in);
X = input.nextInt();
Y = input.nextInt();
Z = input.nextInt();
min1 = Math.min(X, Math.min(Y, Z));
if (min1 == X) {
min2 =Math.min(Y, Z);
min3 =Math.max(Y, Z);
}
if (min1 == Y) {
min2 =Math.min(X, Z);
min3 =Math.max(X, Z);
}
if (min1 == Z) {
min2 = Math.min(X, Y);
min3 = Math.max(X, Y);
}
System.out.print(min1+"\n"+min2+"\n"+min3+"\n\n");
System.out.print(X+"\n"+Y+"\n"+Z+"\n");
}
}





Read More

URI Solution 1041 in C C++ and Java language || Coordinates of a Point



URI Online Judge | 1041

Coordinates of a Point

Adapted by Neilor Tonin, URI  Brazil
Timelimit: 1
Write an algorithm that reads two floating values (x and y), which should represent the coordinates of a point in a plane. Next, determine which quadrant the point belongs, or if you are over one of the Cartesian axes or the origin (x = y = 0).
If the point is at the origin, write the message "Origem".
If the point is over X axis write "Eixo X", else if the point is over Y axis write "Eixo Y".

Input

The input contains the coordinates of a point.

Output

The output should display the quadrant in which the point is.
Input SampleOutput Sample
4.5 -2.2Q4
0.1 0.1Q1
0.0 0.0Origem

URI 1041 Solution in Java language

import java.util.Scanner;
public class URI_1041 {
public static void main(String[] args) {
float X, Y;
Scanner input =new Scanner(System.in);
X = input.nextFloat();
Y = input.nextFloat();
if (X == 0.0 && Y == 0.0) {
System.out.print("Origem\n");
}else if (X == 0.0 && Y != 0.0) {
System.out.print("Eixo Y\n");
}else if (Y == 0.0 && X != 0.0) {
System.out.print("Eixo X\n");
}else if (X > 0.0 && Y > 0.0) {
System.out.print("Q1\n");
}else if (X < 0.0 && Y < 0.0) {
System.out.print("Q3\n");
}else if (X < 0.0 && Y > 0.0) {
System.out.print("Q2\n");
}else  {
System.out.print("Q4\n");
}
}
}

URI 1041 Solution in C language

#include<stdio.h>

int main() {
float X, Y;
scanf("%f%f", &X,&Y);
if (X == 0.0 && Y == 0.0) {
printf("Origem\n");
}else if (X == 0.0 && Y != 0.0) {
printf("Eixo Y\n");
}else if (Y == 0.0 && X != 0.0) {
printf("Eixo X\n");
}else if (X > 0.0 && Y > 0.0) {
printf("Q1\n");
}else if (X < 0.0 && Y < 0.0) {
printf("Q3\n");
}else if (X < 0.0 && Y > 0.0) {
printf("Q2\n");
}else  {
printf("Q4\n");
}

return 0;
}



Read More

All rights reserved ©2016 -URI ONLINE JUDGE SOLUTION | Developed by Maniruzzaman Akash

© 2016 URI ONLINE JUDGE SOLUTION. Developed by Maniruzzaman Akash | Distributed By Gooyaabi Templates
Powered by Blogger.