terça-feira, 30 de maio de 2017

URI PROBLEMA 1079 - Médias Ponderadas SOLUÇÃO EM C

URI Online Judge | 1079
Médias Ponderadas


Adaptado por Neilor Tonin, URI BrasilTimelimit: 1


Leia 1 valor inteiro N, que representa o número de casos de teste que vem a seguir. Cada caso de teste consiste de 3 valores reais, cada um deles com uma casa decimal. Apresente a média ponderada para cada um destes conjuntos de 3 valores, sendo que o primeiro valor tem peso 2, o segundo valor tem peso 3 e o terceiro valor tem peso 5.
Entrada


O arquivo de entrada contém um valor inteiro N na primeira linha. Cada N linha a seguir contém um caso de teste com três valores com uma casa decimal cada valor.
Saída


Para cada caso de teste, imprima a média ponderada dos 3 valores, conforme exemplo abaixo.



URI Online Judge | 1079

Weighted Averages

Adapted by Neilor Tonin, URI  Brazil
Timelimit: 1
Read an integer N, which represents the number of following test cases. Each test case consists of three floating-point numbers, each one with one digit after the decimal point. Print the weighted average for each of these sets of three numbers, considering that the first number has weight 2, the second number has weight 3 and the third number has weight 5.

Input

The input file contains an integer number N in the first line. Each following line is a test case with three float-point numbers, each one with one digit after the decimal point.

Output

For each test case, print the weighted average according with below example.


#include<stdio.h>
int main(){
    float nota1,nota2,nota3,total,media;
    int cont,numero;
    scanf("%d",&numero);
    for(cont=1;cont<=numero;cont++){
        scanf("%f%f%f",&nota1,&nota2,&nota3);
        total=nota1*2.0+nota2*3.0+nota3*5.0;
        media=total/10.0;
        printf("%.1f\n",media);
    }
    return 0;
}

URI PROBLEMA 1075 - Resto 2 SOLUÇÃO EM C

URI Online Judge | 1075
Resto 2


Adaptado por Neilor Tonin, URI BrasilTimelimit: 1


Leia um valor inteiro N. Apresente todos os números entre 1 e 10000 que divididos por N dão resto igual a 2.
Entrada


A entrada contém um valor inteiro N (N < 10000).
Saída


Imprima todos valores que quando divididos por N dão resto = 2, um por linha.



URI Online Judge | 1075

Remaining 2

Adapted by Neilor Tonin, URI  Brazil
Timelimit: 1
Read an integer N. Print all numbers between 1 and 10000, which divided by N will give the rest = 2.

Input

The input is an integer (< 10000)

Output

Print all numbers between 1 and 10000, which divided by n will give the rest = 2, one per line.


#include <stdio.h>

int main(){

int cont, num;

scanf("%d", &num);
for(cont=1;cont<=10000;cont++){
if(cont%num==2){
printf("%d\n", cont);
}
}
return 0;
}


domingo, 28 de maio de 2017

URI PROBLEMA 1066 - Pares, Ímpares, Positivos e Negativos SOLUÇÃO EM C

URI Online Judge | 1066

Pares, Ímpares, Positivos e Negativos

Adaptado por Neilor Tonin, URI  Brasil
Timelimit: 1
Leia 5 valores Inteiros. A seguir mostre quantos valores digitados foram pares, quantos valores digitados foram ímpares, quantos valores digitados foram positivos e quantos valores digitados foram negativos.

Entrada

O arquivo de entrada contém 5 valores inteiros quaisquer.

Saída

Imprima a mensagem conforme o exemplo fornecido, uma mensagem por linha, não esquecendo o final de linha após cada uma.



URI Online Judge | 1066

Even, Odd, Positive and Negative

Adapted by Neilor Tonin, URI  Brazil
Timelimit: 1
Make a program that reads five integer values. Count how many   of these values are even, odd, positive and negative. Print these information like following example.

Input

The input will be 5 integer values.

Output

Print a message like the following example with all letters in lowercase, indicating how many of these values ​​areeven, odd, positive and negative.

#include <stdio.h>

int main() {

    int A,B,C,D,E,F;
  A = 5;
  C = 0;
  D = 0;
  E = 0;
  F = 0;
  
 while(A--){
 scanf("%d", &B);
 if (B < 0)
 D++;
 else if (B > 0)
 C++;
 if (B % 2 == 0)
 E++;
 else
 F++;
 }
 printf("%d valor(es) par(es)\n", E);
 printf("%d valor(es) impar(es)\n", F);
 printf("%d valor(es) positivo(s)\n", C);
 printf("%d valor(es) negativo(s)\n", D);

    return 0;
}

URI PROBLEMA 1061 - Tempo de um Evento SOLUÇÃO EM C

URI Online Judge | 1061

Tempo de um Evento

Adaptado por Neilor Tonin, URI  Brasil
Timelimit: 1
Pedrinho está organizando um evento em sua Universidade. O evento deverá ser no mês de Abril, iniciando e terminando dentro do mês. O problema é que Pedrinho quer calcular o tempo em segundos que o evento vai durar, uma vez que ele sabe quando inicia e quando termina o evento..
Sabendo que o evento pode durar de poucos segundos a vários dias, você deverá ajudar Pedrinho a calcular a duração deste evento.

Entrada

Como entrada, na primeira linha vai haver a descrição “Dia”, seguido de um espaço e o dia do mês no qual o evento vai começar. Na linha seguinte, será informado o momento no qual o evento vai iniciar, no formato hh : mm : ss. Na terceira e quarta linha de entrada haverá outra informação no mesmo formato das duas primeiras linhas, indicando o término do evento.

Saída

Na saída, deve ser apresentada a duração do evento, no seguinte formato:

W dia(s)
X hora(s)
Y minuto(s)
Z segundo(s)


Obs: Considere que o evento do caso de teste para o problema tem duração mínima de 1 minuto.




URI Online Judge | 1061

Event Time

Adapted by Neilor Tonin, URI  Brazil
Timelimit: 1
Peter is organizing an event in his University. The event will be in April month, beginning and finishing within April month. The problem is: Peter wants to calculate the event duration in seconds, knowing obviously the begin and the end time of the event.
You know that the event can take from few seconds to some days, so, you must help Peter to compute the total time corresponding to duration of the event.

Input

The first line of the input contains information about the beginning day of the event in the format: “Dia xx”. The next line contains the start time of the event in the format presented in the sample input. Follow 2 input lines with same format, corresponding to the end of the event.

Output

Your program must print the following output, one information by line, considering that if any information is null for example, the number 0 must be printed in place of W, X, Y or Z:

W dia(s)
X hora(s)
Y minuto(s)
Z segundo(s)


Obs: Consider that the event of the test case have the minimum duration of one minute. “dia” means day, “hora” means hour, “minuto” means minute and “Segundo” means second in Portuguese.






#include<stdio.h>
int main(){
 int dia, diafim, hora, horafim, minuto, minutofinal, segundo, segundofinal;

scanf("Dia %d", &dia);
 scanf("%d : %d : %d\n", &hora, &minuto, &segundo);
 scanf("Dia %d", &diafim);
 scanf("%d : %d : %d", &horafim, &minutofinal, &segundofinal);

segundo = segundofinal - segundo;
 minuto = minutofinal - minuto;
 hora = horafim - hora;
 dia = diafim - dia;

if (segundo < 0){
 segundo += 60;
 minuto--;
 }

 if (minuto < 0){
 minuto += 60;
 hora--;
 }

if (hora < 0){
 hora += 24;
 dia--;
 }

printf("%d dia(s)\n", dia);
 printf("%d hora(s)\n", hora);
 printf("%d minuto(s)\n", minuto);
 printf("%d segundo(s)\n", segundo);
}

sexta-feira, 26 de maio de 2017

URI PROBLEMA 1051 - Imposto de Renda SOLUÇÃO EM C

URI Online Judge | 1051

Imposto de Renda

Por Neilor Tonin, URI  Brasil
Timelimit: 1
Em um país imaginário denominado Lisarb, todos os habitantes ficam felizes em pagar seus impostos, pois sabem que nele não existem políticos corruptos e os recursos arrecadados são utilizados em benefício da população, sem qualquer desvio. A moeda deste país é o Rombus, cujo símbolo é o R$.
Leia um valor com duas casas decimais, equivalente ao salário de uma pessoa de Lisarb. Em seguida, calcule e mostre o valor que esta pessoa deve pagar de Imposto de Renda, segundo a tabela abaixo.

Lembre que, se o salário for R$ 3002.00, a taxa que incide é de 8% apenas sobre R$ 1000.00, pois a faixa de salário que fica de R$ 0.00 até R$ 2000.00 é isenta de Imposto de Renda. No exemplo fornecido (abaixo), a taxa é de 8% sobre R$ 1000.00 + 18% sobre R$ 2.00, o que resulta em R$ 80.36 no total. O valor deve ser impresso com duas casas decimais.

Entrada

A entrada contém apenas um valor de ponto flutuante, com duas casas decimais.

Saída

Imprima o texto "R$" seguido de um espaço e do valor total devido de Imposto de Renda, com duas casas após o ponto. Se o valor de entrada for menor ou igual a 2000, deverá ser impressa a mensagem "Isento".



URI Online Judge | 1051

Taxes

By Neilor Tonin, URI  Brasil
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".


#include <stdio.h>

int main() {
 float salario;
 scanf("%f", &salario);
 if (salario <= 2000.0)
 printf("Isento\n");
 else if (salario <= 3000.0)
 printf("R$ %.2f\n", (salario - 2000.0) * 0.08);
 else if (salario <= 4500.0)
 printf("R$ %.2f\n", 1000.0 * 0.08 + (salario - 3000.0) * 0.18);
 else
 printf("R$ %.2f\n", 1000.0 * 0.08 + 1500.0 * 0.18 + (salario - 4500.0) * 0.28);
    return 0;
}

URI PROBLEMA 1048 - Aumento de Salário SOLUÇÃO EM C

URI Online Judge | 1048

Aumento de Salário

Por Neilor Tonin, URI  Brasil
Timelimit: 1
A empresa ABC resolveu conceder um aumento de salários a seus funcionários de acordo com a tabela abaixo:


Leia o salário do funcionário e calcule e mostre o novo salário, bem como o valor de reajuste ganho e o índice reajustado, em percentual.

Entrada

A entrada contém apenas um valor de ponto flutuante, com duas casas decimais.

Saída

Imprima 3 linhas na saída: o novo salário, o valor ganho de reajuste e o percentual de reajuste ganho, conforme exemplo abaixo.



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:

SalaryReadjustment Rate
0 - 400.00
400.01 - 800.00
800.01 - 1200.00
1200.01 - 2000.00
Above 2000.00
15%
12%
10%
7%
4%

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"

#include<stdio.h>

int main(){
 float salario;
 scanf("%f", &salario);
 if (salario <= 400.0)
 printf("Novo salario: %.2f\nReajuste ganho: %.2f\nEm percentual: 15 %%\n", salario * 1.15, salario * 1.15 - salario);
 else if (salario <= 800.0)
 printf("Novo salario: %.2f\nReajuste ganho: %.2f\nEm percentual: 12 %%\n", salario * 1.12, salario * 1.12 - salario);
 else if (salario <= 1200.0)
 printf("Novo salario: %.2f\nReajuste ganho: %.2f\nEm percentual: 10 %%\n", salario * 1.10, salario * 1.10 - salario);
 else if (salario <= 2000.0)
 printf("Novo salario: %.2f\nReajuste ganho: %.2f\nEm percentual: 7 %%\n", salario * 1.07, salario * 1.07 - salario);
 else
 printf("Novo salario: %.2f\nReajuste ganho: %.2f\nEm percentual: 4 %%\n", salario * 1.04, salario * 1.04 - salario);
 return 0;
}

URI PROBLEMA 1047 - Tempo de Jogo com Minutos SOLUÇÃO EM C

URI Online Judge | 1047

Tempo de Jogo com Minutos

Adaptado por Neilor Tonin, URI  Brasil
Timelimit: 1
Leia a hora inicial, minuto inicial, hora final e minuto final de um jogo. A seguir calcule a duração do jogo.
Obs: O jogo tem duração mínima de um (1) minuto e duração máxima de 24 horas.

Entrada

Quatro números inteiros representando a hora de início e fim do jogo.

Saída

Mostre a seguinte mensagem: “O JOGO DUROU XXX HORA(S) E YYY MINUTO(S)” .


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.


#include <stdio.h>
int main()
{
    int Hora_inicio, final, minuto_inicio, minuto_final, tempo_horatotal, tempo_minutototal;
    scanf("%d %d %d %d", &Hora_inicio, &minuto_inicio, &final, &minuto_final);

    tempo_horatotal = final - Hora_inicio;

    if (tempo_horatotal < 0)
    {
        tempo_horatotal = 24 + (final - Hora_inicio);
    }

 tempo_minutototal = minuto_final - minuto_inicio;
 if (tempo_minutototal < 0)

  {
   tempo_minutototal = 60 + (minuto_final - minuto_inicio);
   tempo_horatotal--;
  }

    if (Hora_inicio == final && minuto_inicio == minuto_final)

    {
        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", tempo_horatotal, tempo_minutototal);
    return 0;
}

URI PROBLEMA 1044 - Múltiplos SOLUÇÃO EM C

URI Online Judge | 1044

Múltiplos

Adaptado por Neilor Tonin, URI  Brasil
Timelimit: 1
Leia 2 valores inteiros (A e B). Após, o programa deve mostrar uma mensagem "Sao Multiplos" ou "Nao sao Multiplos", indicando se os valores lidos são múltiplos entre si.

Entrada

A entrada contém valores inteiros.

Saída

A saída deve conter uma das mensagens conforme descrito acima.



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.

#include <stdio.h>

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

    return 0;
}

segunda-feira, 22 de maio de 2017

URI PROBLEMA 1040 - Média 3 EM C

URI Online Judge | 1040

Média 3

Adaptado por Neilor Tonin, URI  Brasil
Timelimit: 1
Leia quatro números (N1, N2, N3, N4), cada um deles com uma casa decimal, correspondente às quatro notas de um aluno. Calcule a média com pesos 2, 3, 4 e 1, respectivamente, para cada uma destas notas e mostre esta média acompanhada pela mensagem "Media: ". Se esta média for maior ou igual a 7.0, imprima a mensagem "Aluno aprovado.". Se a média calculada for inferior a 5.0, imprima a mensagem "Aluno reprovado.". Se a média calculada for um valor entre 5.0 e 6.9, inclusive estas, o programa deve imprimir a mensagem "Aluno em exame.".
No caso do aluno estar em exame, leia um valor correspondente à nota do exame obtida pelo aluno. Imprima então a mensagem "Nota do exame: " acompanhada pela nota digitada. Recalcule a média (some a pontuação do exame com a média anteriormente calculada e divida por 2). e imprima a mensagem "Aluno aprovado." (caso a média final seja 5.0 ou mais ) ou "Aluno reprovado.", (caso a média tenha ficado 4.9 ou menos). Para estes dois casos (aprovado ou reprovado após ter pego exame) apresente na última linha uma mensagem "Media final: " seguido da média final para esse aluno.

Entrada

A entrada contém quatro números de ponto flutuante correspendentes as notas dos alunos.

Saída

Todas as respostas devem ser apresentadas com uma casa decimal. As mensagens devem ser impressas conforme a descrição do problema. Não esqueça de imprimir o enter após o final de cada linha, caso contrário obterá "Presentation Error".



URI Online Judge | 1040

Average 3

Adapted by Neilor Tonin, URI  Brazil
Timelimit: 1
Read four numbers (N1, N2, N3, N4), which one with 1 digit after the decimal point, corresponding to 4 scores obtained by a student. Calculate the average with weights 2, 3, 4 e 1 respectively, for these 4 scores and print the message "Media: " (Average), followed by the calculated result. If the average was 7.0 or more, print the message "Aluno aprovado." (Approved Student). If the average was less than 5.0, print the message: "Aluno reprovado."(Reproved Student). If the average was between 5.0 and 6.9, including these, the program must print the message "Aluno em exame." (In exam student).
In case of exam, read one more score. Print the message "Nota do exame: " (Exam score) followed by the typed score. Recalculate the average (sum the exam score with the previous calculated average and divide by 2) and print the message “Aluno aprovado.” (Approved student) in case of average 5.0 or more) or "Aluno reprovado."(Reproved student) in case of average 4.9 or less. For these 2 cases (approved or reproved after the exam) print the message "Media final: " (Final average) followed by the final average for this student in the last line.

Input

The input contains four floating point numbers that represent the students' grades.

Output

Print all the answers with one digit after the decimal point.







#include <stdio.h>

int main() {
 double N1, N2, N3, N4, EF, M;
    scanf("%lf %lf %lf %lf", &N1, &N2, &N3, &N4);
   M = (N1*2+N2*3+N3*4+N4)/10;
    printf("Media: %.1f\n", M);
    if (M >= 7.0){
        printf("Aluno aprovado.\n");
    }
    else if (M >= 5.0)
    {
        printf("Aluno em exame.\n");
        scanf("%lf", &EF);
        printf("Nota do exame: %.1f\n", EF);
        if (EF + M / 2.0 > 5.0){
            printf("Aluno aprovado.\n");
    }
    else{
        printf("Aluno reprovado.\n");
    }
        printf("Media final: %.1f\n", (EF + M ) / 2.0);
    }
    else{
        printf("Aluno reprovado.\n");
    }

    return 0;
}

URI PROBLEMA 1036 - Fórmula de Bhaskara EM C

URI Online Judge | 1036

Fórmula de Bhaskara

Adaptado por Neilor Tonin, URI  Brasil
Timelimit: 1
Leia 3 valores de ponto flutuante e efetue o cálculo das raízes da equação de Bhaskara. Se não for possível calcular as raízes, mostre a mensagem correspondente “Impossivel calcular”, caso haja uma divisão por 0 ou raiz de numero negativo.

Entrada

Leia três valores de ponto flutuante (double) A, B e C.

Saída

Se não houver possibilidade de calcular as raízes, apresente a mensagem "Impossivel calcular". Caso contrário, imprima o resultado das raízes com 5 dígitos após o ponto, com uma mensagem correspondente conforme exemplo abaixo. Imprima sempre o final de linha após cada mensagem.


URI Online Judge | 1036

Bhaskara's Formula

Adapted by Neilor Tonin, URI  Brazil
Timelimit: 1
Read 3 floating-point numbers. After, print the roots of bhaskara’s formula. If it's impossible to calculate the roots because a division by zero or a square root of a negative number, presents the message “Impossivel calcular”.

Input

Read 3 floating-point numbers A, B and C.

Output

Print the result with 5 digits after the decimal point or the message if it is impossible to calculate.





















#include <stdio.h>

#include<math.h>




int main() {

double A, B, C, delta;

scanf("%lf %lf %lf", &A, &B, &C);

delta = (B*B)-4*A*C;

if (delta >= 0 && A!=0) {

printf("R1 = %.5lf\n", ((B*-1) + sqrt(delta)) / (2*A));

printf("R2 = %.5lf\n", ((B*-1) - sqrt(delta)) / (2*A));

} else {

printf("Impossivel calcular\n");

}




return 0;

}

URI PROBLEMA 1035 - Teste de Seleção 1 SOLUÇÃO EM C

URI Online Judge | 1035

Teste de Seleção 1

Adaptado por Neilor Tonin, URI  Brasil
Timelimit: 1
Leia 4 valores inteiros A, B, C e D. A seguir, se B for maior do que C e se D for maior do que A, e a soma de C com D for maior que a soma de A e B e se C e D, ambos, forem positivos e se a variável A for par escrever a mensagem "Valores aceitos", senão escrever "Valores nao aceitos".

Entrada

Quatro números inteiros A, B, C e D.

Saída

Mostre a respectiva mensagem após a validação dos valores.


URI Online Judge | 1035

Selection Test 1

Adapted by Neilor Tonin, URI  Brazil
Timelimit: 1
Read 4 integer values A, B, C and D. Then if B is greater than C and D is greater than A and if the sum of C and D is greater than the sum of A and B and if C and D were positives values and if A is even, write the message “Valores aceitos” (Accepted values). Otherwise, write the message “Valores nao aceitos” (Values not accepted).

Input

Four integer numbers A, B, C and D.

Output

Show the corresponding message after the validation of the values​​.












#include <stdio.h>




int main() {




{

int A, B, C, D;

scanf("%d %d %d %d",&A,&B,&C,&D);

if((B>C) && (D>A) && ((C+D)>(A+B)) && (C>0) && (D>0) && (A%2==0))

{

printf("Valores aceitos\n");

}else{

printf("Valores nao aceitos\n");

}

return 0;

}

}

URI PROBLEMA 1016 - Distância SOLUÇÃO EM C

URI Online Judge | 1016

Distância

Adaptado por Neilor Tonin, URI  Brasil
Timelimit: 1
Dois carros (X e Y) partem em uma mesma direção. O carro X sai com velocidade constante de 60 Km/h e o carro Y sai com velocidade constante de 90 Km/h.
Em uma hora (60 minutos) o carro Y consegue se distanciar 30 quilômetros do carro X, ou seja, consegue se afastar um quilômetro a cada 2 minutos.
Leia a distância (em Km) e calcule quanto tempo leva (em minutos) para o carro Y tomar essa distância do outro carro.

Entrada

O arquivo de entrada contém um número inteiro.

Saída

Imprima o tempo necessário seguido da mensagem " minutos".


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.






#include <stdio.h>




int main() {

int Y;

scanf("%d",&Y);

printf("%d minutos\n",Y*2);

return 0;

}

URI PROBLEMA 1015 - Distância Entre Dois Pontos EM C

URI Online Judge | 1015

Distância Entre Dois Pontos

Adaptado por Neilor Tonin, URI  Brasil
Timelimit: 1
Leia os quatro valores correspondentes aos eixos x e y de dois pontos quaisquer no plano, p1(x1,y1) e p2(x2,y2) e calcule a distância entre eles, mostrando 4 casas decimais após a vírgula, segundo a fórmula:
Distancia =

Entrada

O arquivo de entrada contém duas linhas de dados. A primeira linha contém dois valores de ponto flutuante: x1 y1 e a segunda linha contém dois valores de ponto flutuante x2 y2.

Saída

Calcule e imprima o valor da distância segundo a fórmula fornecida, com 4 casas após o ponto decimal.


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.















#include <stdio.h>




int main() {

float x1,y1,x2,y2;

scanf("%f %f",&x1,&y1);

scanf("%f %f",&x2,&y2);

printf("%.4f\n",(sqrt(pow(x2-x1,2)+pow(y2-y1,2))));




return 0;

}

domingo, 21 de maio de 2017

URI PROBLEMA 1012 - Área EM C

URI Online Judge | 1012

Área

Adaptado por Neilor Tonin, URI  Brasil
Timelimit: 1
Escreva um programa que leia três valores com ponto flutuante de dupla precisão: A, B e C. Em seguida, calcule e mostre:
a) a área do triângulo retângulo que tem A por base e C por altura.
b) a área do círculo de raio C. (pi = 3.14159)
c) a área do trapézio que tem A e B por bases e C por altura.
d) a área do quadrado que tem lado B.
e) a área do retângulo que tem lados A e B. 

Entrada

O arquivo de entrada contém três valores com um dígito após o ponto decimal.

Saída

O arquivo de saída deverá conter 5 linhas de dados. Cada linha corresponde a uma das áreas descritas acima, sempre com mensagem correspondente e um espaço entre os dois pontos e o valor. O valor calculado deve ser apresentado com 3 dígitos após o ponto decimal.



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.













#include <stdio.h>




int main() {

float A,B,C;

scanf("%f %f %f",&A,&B,&C);

printf("TRIANGULO: %.3f\n",A*C/2);

printf("CIRCULO: %.3f\n",3.14159*C*C);

printf("TRAPEZIO: %.3f\n",(A+B)*C/2);

printf("QUADRADO: %.3f\n",B*B);

printf("RETANGULO: %.3f\n",A*B);

return 0;

}

URI PROBLEMA 1009 - Salário com Bônus EM C

URI Online Judge | 1009

Salário com Bônus

Adaptado por Neilor Tonin, URI  Brasil
Timelimit: 1
Faça um programa que leia o nome de um vendedor, o seu salário fixo e o total de vendas efetuadas por ele no mês (em dinheiro). Sabendo que este vendedor ganha 15% de comissão sobre suas vendas efetuadas, informar o total a receber no final do mês, com duas casas decimais.

Entrada

O arquivo de entrada contém um texto (primeiro nome do vendedor) e 2 valores de dupla precisão (double) com duas casas decimais, representando o salário fixo do vendedor e montante total das vendas efetuadas por este vendedor, respectivamente.

Saída

Imprima o total que o funcionário deverá receber, conforme exemplo fornecido.


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.






#include <stdio.h>




int main() {




char primeironomedovendedor;

double A,B;

scanf("%s",&primeironomedovendedor);

scanf("%lf %lf",&A,&B);

printf("TOTAL = R$ %.2f\n",(A+B*0.15));




return 0;

}

URI PROBLEMA 1007 - Diferença EM C

URI Online Judge | 1007

Diferença

Adaptado por Neilor Tonin, URI  Brasil
Timelimit: 1
Leia quatro valores inteiros A, B, C e D. A seguir, calcule e mostre a diferença do produto de A e B pelo produto de C e D segundo a fórmula: DIFERENCA = (A * B - C * D).

Entrada

O arquivo de entrada contém 4 valores inteiros.

Saída

Imprima a mensagem DIFERENCA com todas as letras maiúsculas, conforme exemplo abaixo, com um espaço em branco antes e depois da igualdade.


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.





#include <stdio.h>




int main() {

int A,B,C,D;

scanf("%d %d %d %d",&A,&B,&C,&D);

printf("DIFERENCA = %d\n",(A*B-C*D));




return 0;

}

URI PROBLEMA 1133 - Resto da Divisão SOLUÇÃO EM C

URI Online Judge | 1133 Resto da Divisão Adaptado por Neilor Tonin, URI   Brasil Timelimit: 1 Escreva um programa que leia 2 valo...