Saturday, March 28, 2020

URI 2840:: SOLUTION

URI Online Judge | 2840

Balloon++

I hope you are enjoying the competition
We the authors (Diego Rangel, Francisco Arcos, Gabriel Duarte and Gustavo Policarpo), we are happy to be trying to solve our problems. For you who are beginner and do not leave the room without any balloon here is a challenge for you:
  • This year the balloons have a spherical shape, according to the company that produces the balloons: "... for complex engineering reasons, this format is better (...)" will understand ...
  • However this format makes the balloon use more helium gas and this caused a problem because the organizer had already bought a tank with L liters of gas before this novelty in the balloon market.
Knowing the radius of the balloon model and the amount of helium gas available, could you help the team by saying how many balloons can be filled completely?

Input

The input is composed of two integers R and L (1 ≤ RL ≤ 109) the radius and the amount of gas available respectively.
Consider PI = 3.1415

Output

You must print a single integer representing the amount of balloons that can be filled with the amount of helium gas available.
Input SamplesOutput Samples
4 400014
2 501



[WAIT]
     First of all, think yourself that you have tried enough for the problem. If you did not please read the program once. REMEMBER one thing, just believe in yourself.....YOU CAN.....YOU KNOW....



See the ANSWER here...

URI 2758:: SOLUTION

URI Online Judge | 2758

Floating Number Input and Output

Your teacher would like to make a program with the following characteristics:
  1. Create two variables to store real numbers of simple precision;
  2. Create two variables to store double precision real numbers;
  3. Read the first simple precision number that will always have a decimal;
  4. Read the second simple precision number that will always have two decimal places;
  5. Read the first double precision number that will always have three decimal places;
  6. Read the second double precision number that will always have four decimal places;
  7. Print the letter A, a blank, the equals sign, a blank, the number stored in the first variable read in step 3, a comma, a blank, the letter B, a blank, the sign of equal, a space, the number stored in the second variable read in step 4. Do not forget to skip line;
  8. Print the letter C, a blank, the equal sign, a blank, the number stored in the first variable read in step 5, a comma, a blank, the letter D, a blank, the sign of equal, a space, the number stored in the second variable read in step 6. Do not forget to skip line;
  9. Repeat procedure 7, printing the numbers with one decimal place;
  10. Repeat procedure 8, printing the numbers with one decimal place;
  11. Repeat procedure 7, printing the numbers to two decimal places;
  12. Repeat procedure 8, printing the numbers to two decimal places;
  13. Repeat procedure 7, printing the numbers to three decimal places;
  14. Repeat procedure 8, printing the numbers to three decimal places;
  15. Repeat procedure 7, printing the numbers to three decimal places and in the form of scientific notation with the character E;
  16. Repeat procedure 8, printing the numbers to three decimal places and in the form of scientific notation with the character E;
  17. Repeat procedure 7, printing only the whole part of the number;
  18. Repeat procedure 8, printing only the entire part of the number.

Input

The input consists of several test files. Each test file has two rows. In the first line there are two real numbers A and B (-1000.0 ≤ A, B ≤ 1000.0), separated by white space. In the second line there are two real numbers C and D (-1000.0 ≤ C, D ≤ 1000.0), separated by white space. As shown in the following input example.

Output

For each file in the input, you have an output file. The output file has twelve rows as described in item 7 and 8. As shown in the following output example.
Input SamplesOutput Samples
1.2 3.45
3.451 3.4516
A = 1.200000, B = 3.450000
C = 3.451000, D = 3.451600
A = 1.2, B = 3.5
C = 3.5, D = 3.5
A = 1.20, B = 3.45
C = 3.45, D = 3.45
A = 1.200, B = 3.450
C = 3.451, D = 3.452
A = 1.200E+00, B = 3.450E+00
C = 3.451E+00, D = 3.452E+00
A = 1, B = 3
C = 3, D = 3
2127.9 -821.45
-1020.456 1352.4548
A = 2127.899902, B = -821.450012
C = -1020.456000, D = 1352.454800
A = 2127.9, B = -821.5
C = -1020.5, D = 1352.5
A = 2127.90, B = -821.45
C = -1020.46, D = 1352.45
A = 2127.900, B = -821.450
C = -1020.456, D = 1352.455
A = 2.128E+03, B = -8.215E+02
C = -1.020E+03, D = 1.352E+03
A = 2128, B = -821
C = -1020, D = 1352



[WAIT]
     First of all, think yourself that you have tried enough for the problem. If you did not please read the program once. REMEMBER one thing, just believe in yourself.....YOU CAN.....YOU KNOW....



See the ANSWER here...

URI 2749:: SOLUTION

URI Online Judge | 2749

Output 3

Your teacher would like to make a screen with the following characteristics:
  1. Have 39 dashes (-) on the first line;
  2. Have a | underneath the first dash and the thirty-ninth dash of the first line, below the 2nd dash you should start typing "x = 35" and the rest fill in with whitespace;
  3. Have a | below the first dash and the thirty-ninth dash of the first line, fill in the middle with whitespace;
  4. Have a | below the first dash and the thirty-ninth dash of the first line, below the 17th dash you should start typing "x = 35" and the rest fill in with whitespace;
  5. Repeat procedure 3;
  6. Have a | under the first dash and the thirty-ninth dash of the first line, under the 33rd dash you should start typing "x = 35" and the rest fill in the middle with whitespace;
  7. Repeat procedure 1.
At the end should look like the following image:

--------------------------------------- (39 dashes)
|x = 35                               |
|                                     |
|                x = 35               |
|                                     |
|                               x = 35|
--------------------------------------- (39 dashes)

Input

There is not.

Output

The output will be printed as shown above.
Input SampleOutput Sample
---------------------------------------
|x = 35                               |
|                                     |
|                x = 35               |
|                                     |
|                               x = 35|
---------------------------------------



[WAIT]
     First of all, think yourself that you have tried enough for the problem. If you did not please read the program once. REMEMBER one thing, just believe in yourself.....YOU CAN.....YOU KNOW....



See the ANSWER here...

URI 2748:: SOLUTION

URI Online Judge | 2748

Output 2

Your teacher would like to make a screen with the following characteristics:
  1. Have 39 dashes (-) on the first line;
  2. Have a | underneath the first dash and the thirty-ninth dash of the first line, below the dash should begin to write the word "Roberto" and the rest fill in the middle with white space;
  3. Have a | below the first dash and the thirty-ninth dash of the first line, fill in the middle with whitespace;
  4. Have a | below the first dash and the thirty-ninth dash of the first line, below the 10 dash you should begin to type the number "5786" and the rest fill in the middle with whitespace;
  5. Repeat procedure 3;
  6. Have a | underneath the first dash and the thirty-ninth dash of the first line, below the dash 10 should begin to write the word "UNIFEI" and the rest fill in the middle with white space;
  7. Repeat procedure 1.
At the end should look like the following image:

--------------------------------------- (39 traces)
|        Roberto                      |
|                                     |
|        5786                         |
|                                     |
|        UNIFEI                       |
--------------------------------------- (39 traces)

Input

There is not.

Output

The output will be printed as shown above.
Input SampleOutput Sample
---------------------------------------
|        Roberto                      |
|                                     |
|        5786                         |
|                                     |
|        UNIFEI                       |
---------------------------------------



[WAIT]
     First of all, think yourself that you have tried enough for the problem. If you did not please read the program once. REMEMBER one thing, just believe in yourself.....YOU CAN.....YOU KNOW....



See the ANSWER here...

Monday, November 18, 2019

URI 2060:: SOLUTION

URI Online Judge | 2060

Bino's Challenge

Bino and Cino are close friends. Bino likes to create mathematical challenges to Cino. This time, Bino created a list of numbers and asked to Cino: How many numbers are multiples of 234 and 5?
This challenge looks simple, but when the list contains many numbers, Cino makes some miscalculations. To help Cino, make a program to solve the Bino's Challenge.

Input

The first line of input consists of an integer (1 ≤ N ≤1000), representing the amount of numbers in the Bino's list.
The second line contains N integers Li (1 ≤ Li ≤ 100), representing the numbers of the Bino's list.

Output

Print the amount of multiples of 234 and 5 in the list. Note the formatting of the output in the output sample, because it must be followed strictly. "Multiplo(s)" means "Multiple(s)" in English, but you must print the message in Portuguese.
Input SampleOutput Sample
5
2 5 4 20 10
4 Multiplo(s) de 2
0 Multiplo(s) de 3
2 Multiplo(s) de 4
3 Multiplo(s) de 5



[WAIT]
     First of all, think yourself that you have tried enough for the problem. If you did not please read the program once. REMEMBER one thing, just believe in yourself.....YOU CAN.....YOU KNOW....



See the ANSWER here...

Thursday, November 14, 2019

URI 1308:: SOLUTION

URI Online Judge | 1308

Etruscan Warriors Never Play Chess

A troop of Etruscan warriors is organized as follows. In the first row, there is only one warrior; then, the second row contains two warriors; the third row contains three warriors, and so on. In general, each row i contains i warriors.
We know the number of Etruscan warriors of a given troop. You have to compute the number of rows in which they are organized.
Please note that there may be some remaining warriors (this could happen if they are not enough to form the next row). For example, 3 warriors are organized in 2 rows. With 6 warriors you can form 3 rows; but you can also form 3 rows with 7, 8 or 9 warriors.

Input

The first line of the input contains an integer indicating the number of test cases. For each test case, there is a single integer N (0 ≤ N ≤ 1018), indicating the number of Etruscan warriors.

Output

For each test case, the output should contain a single integer indicating the number of rows that can be formed.
Sample InputSample Output
6
3
6
7
8
9
10
2
3
3
3
3
4



[WAIT]
     First of all, think yourself that you have tried enough for the problem. If you did not please read the program once. REMEMBER one thing, just believe in yourself.....YOU CAN.....YOU KNOW....



See the ANSWER here...

Tuesday, November 12, 2019

URI 1051:: SOLUTION

URI Online Judge | 1051

Taxes

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


[WAIT]
     First of all, think yourself that you have tried enough for the problem. If you did not please read the program once. REMEMBER one thing, just believe in yourself.....YOU CAN.....YOU KNOW....



See the ANSWER here...

Sunday, May 12, 2019

URI 2674:: SOLUTION

URI Online Judge | 2674

Super Primes: Engage!

The Association of Indivisible Primes ​​elected a category of prime numbers called Super Primes. A number is considered super prime if in addition to being prime, all its digits are prime, too. The Association asked you to make a program to characterize the numbers.

Input

The input contains several test cases, each test case being an integer N (0 < N < 105) on a single line. The entry ends in the last test case.

Output

For each test case, the entry number classification is expected in a single line, which can be: "Super", if the number is a Super Prime; "Primo" if the number by a prime number only; Or "Nada" if the number has divisors beyond 1 and itself.
Input SampleOutput Sample
23
33
43
Super
Nada
Primo


[WAIT]


     First of all, think yourself that you have tried enough for the problem. If you did not please read the program once. REMEMBER one thing, just believe in yourself.....YOU CAN.....YOU KNOW....

See the ANSWER here...

Tuesday, May 7, 2019

URI 1028:: SOLUTION

URI Online Judge | 1028

Collectable Cards

Richard and Vicent are crazy about football collectable cards. In their spare time, they arrange a way of playing some game involving such cards. Both also have the habit of exchanging the repeated cards with their friends, and one day they thought about a different game. They called all their friends and proposed the following: with the cards in hand, each one tried to make an exchange with his closest friend following this simple rule: each one must count how many cards he owned. After this, they had to split these cards into stacks, all of it with the same size, as large as it was possible for both players. Then, each one choose one of the friend's card stacks to receive. For example, if Richard and Vincent would change the cards with respectively 8 and 12 cards each, both must put his cards in stacks of four cards (Richard would have two stacks and Vincent had three stacks), and both choose a stack from his friend to receive it.

Input

The first input line contains a single integer N (1 ≤ N ≤ 3000), indicating the number of test cases. Each test case contains two integer numbers F1 (1 ≤ F1 ≤ 1000) and F2 (1 ≤ F2 ≤ 1000)  indicating, respectly, the among of collectable cards that Richard and Vicent have to change.

Output

For each test case there will be an integer number at the output, representing the maximum size of the stack of cards which can be exchanged between two players.
Input SampleOutput Sample
3
8 12
9 27
259 111
4
9
37



[WAIT]


     First of all, think yourself that you have tried enough for the problem. If you did not please read the program once. REMEMBER one thing, just believe in yourself.....YOU CAN.....YOU KNOW....

See the ANSWER here...

Friday, February 1, 2019

URI 1177:: SOLUTION

URI Online Judge | 1177

Array Fill II

Write a program that reads a number T and fill a vector N[1000] with the numbers from 0 to T-1 repeated times, like as the example below.

Input

The input contains an integer number T (2 ≤ T ≤ 50).

Output

For each position of the array N, print "N[i] = x", where i is the array position and is the number stored in that position.
Input SampleOutput Sample
3N[0] = 0
N[1] = 1
N[2] = 2
N[3] = 0
N[4] = 1
N[5] = 2
N[6] = 0
N[7] = 1
N[8] = 2
...




[WAIT]
     First of all, think yourself that you have tried enough for the problem. If you did not please read the program once. REMEMBER one thing, just believe in yourself.....YOU CAN.....YOU KNOW....



See the ANSWER here...
                                                                 

URI 1176:: SOLUTION

URI Online Judge | 1176

Fibonacci Array

Write a program that reads a number and print the Fibonacci number corresponding to this read number. Remember that the first elements of the Fibonacci series are 0 and 1 and each next term is the sum of the two preceding it. All the Fibonacci numbers calculated in this program must fit in a unsigned 64 bits number.

Input

The first line of the input contains a single integer T, indicating the number of test cases. Each test case contains a single integer N (0 ≤ N ≤ 60), corresponding to the N-th term of the Fibonacci series.

Output

For each test case in the input, print the message "Fib(N) = X", where X is the N-th term of the Fibonacci series.
Input SampleOutput Sample
3
0
4
2
Fib(0) = 0
Fib(4) = 3
Fib(2) = 1




[WAIT]
     First of all, think yourself that you have tried enough for the problem. If you did not please read the program once. REMEMBER one thing, just believe in yourself.....YOU CAN.....YOU KNOW....


See the ANSWER here...
                                                                  

URI 1178:: SOLUTION

URI Online Judge | 1178

Array Fill III

Read a number X. Put this X at the first position of an array [100]. In each subsequent position (1 up to 99) put half of the number inserted at the previous position, according to the example below. Print all the vector N.

Input

The input contains a double precision number with four decimal places.

Output

For each position of the array N print "N[i] = Y", where i is the array position and Y is the number stored in that position. Each number of N[...] must be printed with 4 digits after the decimal point.
Input SampleOutput Sample
200.0000N[0] = 200.0000
N[1] = 100.0000
N[2] = 50.0000
N[3] = 25.0000
N[4] = 12.5000
...




[WAIT]
     First of all, think yourself that you have tried enough for the problem. If you did not please read the program once. REMEMBER one thing, just believe in yourself.....YOU CAN.....YOU KNOW....


See the ANSWER here...
                                                                 

URI 1180:: SOLUTION

URI Online Judge | 1180

Lowest Number and Position

Write a program that reads a number N. This is the size of a array X[N]. Next, read each of the numbers of X, find the smallest element of this array and its position within the array, printing this information.

Input

The first line of input contains one integer (1 < <1000), indicating the number of elements that should be read to an array X[N] of integer numbers. The second row contains each of the N values, separated by a space.

Output

The first line displays the message “Menor valor:” followed by a space and the lowest number read in the input. The second line displays the message “Posicao:” followed by a space and the array position in which the lowest number is, remembering that the array starts at the zero position.
Input SampleOutput Sample
10
1 2 3 4 -5 6 7 8 9 10
Menor valor: -5
Posicao: 4




[WAIT]
     First of all, think yourself that you have tried enough for the problem. If you did not please read the program once. REMEMBER one thing, just believe in yourself.....YOU CAN.....YOU KNOW....



See the ANSWER here...
                                                                

URI 1181:: SOLUTION

URI Online Judge | 1181

Line in Array

Your job in this problem is to read a number that is a line of an array, an uppercase character, indicating the operation to be performed and all elements of a bidimentional array M[12][12]. Then, you have to calculate and print the sum or average of all elements within the green area according to the case. The following figure illustrates the case when is entered the number 2 to the array line, showing all elements that must be considered in the operation.

Input

The first line of the input contains a simple integer L (0 ≤ L ≤ 11) indicating the line to be considered in the operation. The second line of the input contains a single uppercase character T ('S' or 'M'), indicating the operation Sum or Average (Média in portuguese) to be performed with the elements of the array. Follow the 144 floating-point numbers of the array, considering that the elements are inserted line by line, from line 0 to line 11, always from left to right.

Output

Print the calculated result (sum or average), with one digit after the decimal point.
Input SampleOutput Sample
2
S
1.0
-3.5
2.5
4.1
...
12.6




[WAIT]
     First of all, think yourself that you have tried enough for the problem. If you did not please read the program once. REMEMBER one thing, just believe in yourself.....YOU CAN.....YOU KNOW....



See the ANSWER here...
                                                                  

URI 1182:: SOLUTION

URI Online Judge | 1182

Column in Array

Your job in this problem is to read a number that is a column of an array where an operation will be performed, an uppercase character, indicating the operation to be performed and all elements of a bidimentional array M[12][12]. Then, you have to calculate and print the sum or average of all elements within the green area according to the case. The following figure illustrates the case when is entered the number 5 to the array column, showing all elements that must be considered in the operation.

Input

The first line of the input contains a simple integer C (0 ≤ C ≤ 11) indicating the column to be considered in the operation. The second line of the input contains a single uppercase character T ('S' or 'M'), indicating the operation Sum or Average (Média in portuguese) to be performed with the elements of the array. Follow 144 floating-point numbers of the array.

Output

Print the calculated result (sum or average), with one digit after the decimal point.
Input SampleOutput Sample
5
S
1.0
-3.5
2.5
4.1
...
12.6




[WAIT]
     First of all, think yourself that you have tried enough for the problem. If you did not please read the program once. REMEMBER one thing, just believe in yourself.....YOU CAN.....YOU KNOW....



See the ANSWER here...
                                                               

URI 1197:: SOLUTION

URI Online Judge | 1197

Back to High School Physics

A particle has initial velocity and constant acceleration. If its velocity after certain time is v then what will its displacement be in twice of that time?

Input

The input will contain two integers in each line. Each line makes one set of input. These two integers denote the value of (-100 ≤ ≤ 100) and t(0 ≤ ≤ 200) ( means at the time the particle gains that velocity). The end of the input is determined by EOF.

Output

For each line of input print a single integer in one line denoting the displacement in double of that time.
Input SampleOutput Sample
0 0
5 12
0
120




[WAIT]
     First of all, think yourself that you have tried enough for the problem. If you did not please read the program once. REMEMBER one thing, just believe in yourself.....YOU CAN.....YOU KNOW....


                                                                  ::SOLUTION::



#include<stdio.h>

int main()
{
    int a, v, t;
    while(scanf("%d %d",&v,&t)!=EOF)
    {
        a = 2*v*t;
        printf("%d\n",a);
    }
    return 0;
}

URI 1198:: SOLUTION

URI Online Judge | 1198

Hashmat the Brave Warrior

Hashmat is a brave warrior who with his group of young soldiers moves from one place to another to fight against his opponents. Before fighting he just calculates one thing, the difference between his soldier number and the opponent's soldier number. From this difference he decides whether to fight or not. Sometimes Hashmat's soldier number is greater than his opponent.

Input

The input contains two integer numbers in every line. These two numbers in each line denotes the number of soldiers in Hashmat's army and his opponent's army or vice versa. The input numbers are not greater than 232. Input is terminated by End of File.

Output

For each line of input, print the difference of number of soldiers between Hashmat's army and his opponent's army. Each output should be in seperate line.
Input SampleOutput Sample
10 12
10 14
100 200
2
4
100




[WAIT]
     First of all, think yourself that you have tried enough for the problem. If you did not please read the program once. REMEMBER one thing, just believe in yourself.....YOU CAN.....YOU KNOW....


                                                                  ::SOLUTION::



#include<stdio.h>

int main()
{
    long long int a, b, d;
    while(scanf("%lld %lld",&a, &b)!=EOF)
    {
        if(a>=b)
        {
            d = a-b;
        }
        else
        {
            d = b-a;
        }
        printf("%lld\n",d);
    }
    return 0;
}

URI 1164:: SOLUTION

URI Online Judge | 1164

Perfect Number

In mathematics, a perfect number is an integer for which the sum of all its own positive divisors (excluding itself) is equal to the number itself. For example the number 6 is perfect, because 1+2+3 is equal to 6. Your task is to write a program that read integer numbers and print a message informing if these numbers are perfect or are not perfect.

Input

The input contains several test cases. The first contains the number of test cases (1 ≤ N ≤ 100). Each one of the following N lines contains an integer X (1 ≤ X ≤ 108), that can be or not a perfect number.

Output

For each test case print the message “eh perfeito” (is perfect) or “nao eh perfeito” (X isn't perfect) according with to above specification.
Input SampleOutput Sample
3
6
5
28
6 eh perfeito
5 nao eh perfeito
28 eh perfeito



[WAIT]
     First of all, think yourself that you have tried enough for the problem. If you did not please read the program once. REMEMBER one thing, just believe in yourself.....YOU CAN.....YOU KNOW....


See the ANSWER here...
                                                                  

URI 1165:: SOLUTION

URI Online Judge | 1165

Prime Number

A Prime Number is a number that is divisible only by 1 (one) and by itself. For example the number 7 is Prime, because it can be divided only by 1 and by 7.

Input

The input contains several test cases. The first contains the number of test cases (1 ≤ N ≤ 100). Each one of the following N lines contains an integer X (1 < X ≤ 107), that can be or not a prime number.

Output

For each test case print the message “eh primo” (is prime) or “nao eh primo” (X isn't prime) according with to above specification.
Input SampleOutput Sample
3
8
51
7
8 nao eh primo
51 nao eh primo
7 eh primo



[WAIT]
     First of all, think yourself that you have tried enough for the problem. If you did not please read the program once. REMEMBER one thing, just believe in yourself.....YOU CAN.....YOU KNOW....


See the ANSWER here....
                                                          

URI 1168:: SOLUTION

URI Online Judge | 1168

LED

John wants to set up a panel containing different numbers of LEDs. He does not have many leds, he is not sure if he will be able to mount the desired number. Considering the configuration of the LEDs of the numbers below, make an algorithm that helps John to discover the number of LEDs needed to set the value.

Input

The input contains an integer N, (1 ≤ N ≤ 2000) corresponding to the number of test cases, followed by N lines, each line containing a number (1 ≤ V ≤ 10100corresponding to the value that John wants to set with the leds.

Output

For each test case, print one line containing the number of LEDs that John needs to set the desired value, followed by the word "leds".
Input SampleOutput Sample
3
115380
2819311
23456
27 leds
29 leds
25 leds



[WAIT]
     First of all, think yourself that you have tried enough for the problem. If you did not please read the program once. REMEMBER one thing, just believe in yourself.....YOU CAN.....YOU KNOW....


See the ANSWER here...