Skip to main content

Posts

Showing posts from February, 2021

URI Problem 2936 Solution How Much Cassava? - URI Online Judge Solution

URI Online Judge Solution 2936 How Much Cassava? Using Python Programming Language. Every year in April, the Curupira, Boitatá, the pink Boto (this one in his man form, as Dona Chica likes it better), Mapinguari and Iara meet at Dona Chica to remember their moments with Mani, the beautiful girl with the white skin. And as it could not be different the main dish of this meeting is the cassava. Each one of them eats one to ten servings of cassava and they always warn Dona. Chica in advance about how many servings they will eat that day. The size of the portion of each is different, but they are always the same. The portions are as follows (in grams):  Curupira eats 300  Boitatá eats 1500  Boto eats 600  Mapinguari eats 1000  Iara eats 150    Dona chica in turn always eats 225 grams of cassava. Tired of every year having to figure out how much cassava to prepare she contacted you to write a program that tells how much cassava should be prepared in grams. Input   The input consists of 5 in

URI Problem 2896 Solution Enjoy the Offer - URI Online Judge Solution

URI Online Judge Solution 2896 Enjoy the Offer Using Python Programming Language. A supermarket is doing a sales promotion for soft drinks. If one day you buy soft drinks and bring the empty bottles the next day, they exchange each set of K empty bottles for a full one. A customer wants to make the most of this offer and therefore bought several bottles on the first day of the promotion. Now he wants to know how many bottles he will have at the end of the second day of the promotion if he use it to the fullest.  Make a program to calculate this.  Input   The first input line contains integer T (1 ≤ T ≤ 10000), which indicates the number of test cases. In each of the following T lines come two integers N and K (1 ≤ K, N ≤ 10000), respectively the number of soft drinks bought and the number of empty bottles to gain a full.  Output   For each test case print the number of bottles that the customer will have on the second day, if he makes the most of the offer. Input Sample Output Sample 3

URI Problem 2867 Solution Digits - URI Online Judge Solution

URI Online Judge Solution 2867 Digits Using Python Programming Language.   Given two integers, n and m , how many digits have  n m   ?  Examples:  2 and 10 - 210 = 1024 - 4 digits 3 and  9 - 39 = 19683 - 5 digits  Input   The input is composed of several test cases. The first line has an integer C, representing the number of test cases. The following C lines contain two integers N and M (1 <= N, M <= 100).  Output   For each input test case of your program, you must print an integer containing the number of digits of the result of the calculated power in the respective test case. URI 2867 Solution in Python: T = int(input()) while T>0: A,B = map(int,input().split()) A = A**B A = len(str(A)) print(A) T-=1

URI Problem 2861 Solution The Output - URI Online Judge Solution

URI Online Judge Solution 2861 The Output Using Python Programming Language.   Cacunda, Bizz and Massacote are inseparable friends. In college, in a few days, they did not go to class to play tricks. One day a teacher was passing by. At the same time, the three of them shouted the word "gzuz" loudly. After this cry, they became invisible, and the teacher did not see them. Again, their class was answering questions from the teacher. When it was the turn of one of them, they would respond with the word "gzuz", and the teacher would accept the answer and give the maximum mark of the question. Make the simulation of the output they found to get out of the most diverse problems.  Input  The input is composed of several test cases. The first line contains an integer C (2 <= C <= 99) relative to the number of questions the teacher has asked. The following C lines come with a question asked by the teacher.  Output   For each question, print the answer that was said b

URI Problem 2791 Solution Bean - URI Online Judge Solution

URI Online Judge Solution 2791 Bean Using Python Programming Language.  It is said in the surroundings of Montes Claros that, long ago in the municipal market, Sebastião and his companions of work always play a game of divination after the delivery of agricultural products harvested in the week that happened. The game, "Guess Where the Bean is", consists in hiding a grain of beans in one of four opaque glasses, and after shuffling them, the bettor must guess in which glass the vegetable is.  This year, due to the great cultural and historical success and the enormous amount of people who practice this game in the municipal market, the city council decided to hold a "Guess Where the Bean is '' championship. However, she needs a program to show viewers where the beans were after the end of a game. Knowing that the next Programming Marathon will take place in the city, she soon commissioned a solution from the excellent programmers. In this way, you should assist th

URI Problem 2787 Solution Chess - URI Online Judge Solution

URI Online Judge Solution 2787 Chess Using Python Programming Language.  In the chessboard, the square of the board on line 1, column 1 (upper left corner) is always white and the colors of the houses alternate between white and black, according to the pattern known as ... chess! In this way, since the traditional board has eight rows and eight columns, the house on row 8, column 8 (lower right corner) will also be white. In this problem, however, we want to know the color of the square of the board in the lower right corner of a tray with any dimensions: L rows and C columns. In the example of the figure, for L = 6 and C = 9, the square of the board in the lower right corner will be black!  Input   The first line of the input contains an integer L (1 ≤ L ≤ 1000) indicating the number of lines in the chessboard. The second line of the input contains an integer C (1 ≤ C ≤ 1000) representing the number of columns.  Output   Print a line on the output. The line should contain an integer,

URI Problem 2764 Solution Date Input and Output - URI Online Judge Solution

URI Online Judge Solution 2764 Date Input and Output Using Python Programming Language.   Your teacher would like to make a program with the following characteristics: Read a date in the DD/MM/YY format; Print the date in MM/DD/YY format; Print the date in the YY/MM/DD format ; Print the date in DD-MM-YY format.  Input   The input consists of several test files. In each test file there is one line. The line has the following DD/MM/YY format where DD, MM and YY are integers. As shown in the following input example.  Output   For each file in the entry, you have an output file. The output file has three lines according to procedures 2, 3, and 4. As shown in the following output example. Input Samples Output Samples 02/08/10 08/02/10 10/08/02 02-08-10 29/07/03 07/29/03 03/07/29 29-07-03 URI 2764 Solution in Python: D = input() DD = D[0]+D[1] MM = D[3]+D[4] YY = D[6]+D[7] print(MM+'/'+DD+'/'+YY) print(YY+'/'+MM+'/'+DD) print(DD+'-'+MM+'-'+

URI Problem 2756 Solution Output 10 - URI Online Judge Solution

URI Online Judge Solution 2756 Output 10 Using Python Programming Language.  Your programming teacher would like you to do a program with the following characteristics:  Put seven blanks and put the 'A' character;  Put six blanks and place the character 'B', a space and the character 'B';  Put five blanks and place the 'C' character, three white space, and the 'C' character;  Put four blanks and place the 'D' character, five white space, and the 'D' character;  Put three blanks and put the 'E' character, seven white space and the 'E' character;  Repeat procedure 4;  Repeat procedure 3;  Repeat procedure 2;  Repeat procedure 1.  Input   There is not.  Output   The result of your program should be written according to the output example. Input Sample Output Sample A B B C C D D E E D D C C B B A   URI 2756 Solution in Python: print(" A&q

URI Problem 2753 Solution Output 7 - URI Online Judge Solution

URI Online Judge Solution 2753 Output 7 Using Python Programming Language.   Your teacher would like you to do a program with the following characteristics:  Create twenty-six integers;  Assign the first variable the value 97;  Assign the other variables to the value of the first sum of a unit;  Show on the screen the numeric values of the first variable, a space in arm, the character 'e', another white space and its alphanumeric value (characters);  Repeat for all other variables.  Input  There is not.  Output  The result of your program should be the same as the output example. Input Sample Output Sample 97 e a 98 e b 99 e c 100 e d 101 e e 102 e f 103 e g 104 e h 105 e i 106 e j 107 e k 108 e l 109 e m 110 e n 111 e o 112 e p 113 e q 114 e r 115 e s 116 e t 117 e u 118 e v 119 e w 120 e x 121 e y 122 e z URI 2753 Solution in Python: print("97 e a") print("98 e b") print("99 e c") print("100 e d") print("101 e e") print(&quo

URI Problem 2748 Solution Output 2 - URI Online Judge Solution

URI Online Judge Solution 2748 Output 2 Using Python Programming Language.  Your teacher would like to make a screen with the following characteristics:  Have 39 dashes (-) on the first line;  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;  Have a | below the first dash and the thirty-ninth dash of the first line, fill in the middle with whitespace;  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;  Repeat procedure 3;  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;  Repeat procedure 1.    At the end should look like the following image: ----------

URI Problem 2747 Solution Output 1 - URI Online Judge Solution

URI Online Judge Solution 2747 Output 1 Using Python Programming Language.  Your programming teacher would like to make a screen with the following characteristics:  Have 39 dashes (-) on the first line;  Have a | below the first dash and the thirty-ninth dash of the first line, fill in the middle with whitespace;  Repeat procedure 2 plus four times;  Repeat procedure 1.  At the end should look like the following image:  --------------------------------------- (39 traces) | | | | | | | | | | --------------------------------------- (39 traces) Input   There is no.  Output  The output will be printed as shown above. Input Sample Output Sample --------------------------------------- | | | | | | |

URI Problem 2746 Solution Viruses - URI Online Judge Solution

URI Online Judge Solution 2746 Viruses Using PostgreSQL Query Language.   Viruses are evolving, but new research has proven that by switching some proteins the vaccine becomes unbeatable. The protein H1(Hemagglutinin) when replaced by the X protein (Xenomorphina) has interesting effects against almost every viral disease. Some conspiracists say that after the vaccine’s discovery some strange 3 meters tall creatures were found in the surroundings of the laboratories, but this is clearly a lie.  Therefore, you must replace every string “H1”( Hemagglutinin ) by 'X' ( Xenomorphina ). Schema virus Column Type id (PK) integer name varchar Tables virus id name 1 H1RT 2 H7H1 3 HUN8 4 XH1HX 5 XXXX Output Sample name XRT H7X HUN8 XXHX XXXX    URI 2746 Solution in PostgreSQL: SELECT REPLACE(name,'H1','X')as "name" FROM VIRUS;

URI Problem 2745 Solution Taxes - URI Online Judge Solution

URI Online Judge Solution 2745 Taxes Using PostgreSQL Query Language.   You are going to the International Personal Tax meeting and your proposal is: every individual with income higher than 3000 must pay a tax to the government, which is 10% of his/her income.  Show the name and the tax value of each person who earns more than 3000, with two decimal places of precision. Schema people Column Type id (PK) integer name varchar salary numeric Tables people id name salary 1 James M. Tabarez 883 2 Rafael T. Hendon 4281 3 Linda J. Gardner 4437 4 Nicholas J. Conn 8011 5 Karol A. Morales 2508 6 Lolita S. Graves 8709 Output Sample name tax Rafael T. Hendon 428.10 Linda J. Gardner 443.70 Nicholas J. Conn 801.10 Lolita S. Graves 870.90   URI 2745 Solution in PostgreSQL: SELECT name,ROUND((salary*10)/100,2) AS tax FROM people WHERE salary>3000

URI Problem 2744 Solution Passwords - URI Online Judge Solution

URI Online Judge Solution 2744 Passwords Using PostgreSQL Query Language.  You were hired to be the consultant for a company. Analyzing the database, you noticed that the passwords are stored as text files and, as everyone knows, this is a terrible security practice as they are not encrypted.  Therefore you must convert every password to the MD5 format. Show the client id, the password before conversion and the new MD5. Schema account Column Type id (PK) integer name varchar login varchar password varchar Tables account id name login password 1 Joyce P. Parry Promeraw noh1Oozei 2 Michael T. Gonzalez Phers1942 Iath3see9bi 3 Heather W. Lawless Hankicht diShono4 4 Otis C. Hitt Conalothe zooFohH7w 5 Roger N. Brownfield Worseente fah7ohNg Output Sample id password MD5 1 noh1Oozei b67ed42ced0e0a19ce7ed904bb94b607 2 Iath3see9bi 66877b2da87fb09af3f5602f31c6d35c 3 diShono4 d19c9be4c00c683a4688948b81eb2a1d 4 zooFohH7w 202b76ed4a556fdbf409505a8023695e 5 fah7ohNg 05b3dccaa70f228f1bedc7a285e50d9d U

URI Problem 2743 Solution Number of Characters - URI Online Judge Solution

URI Online Judge Solution 2743 Number of Characters Using PostgreSQL Query Language. The Global Organization of Characters at People’s Names (GOCPN) made a census to figure how many characters people have in theirs names.  To help OMCNP, you must show the number of characters of each name sorted by decreasing number of characters. Schema people Column Type id (PK) integer name varchar Tables people id name 1 Karen 2 Manuel 3 Ygor 4 Valentine 5 Jo Output Sample name length Valentine 9 Manuel 6 Karen 5 Ygor 4 Jo 2   URI 2743 Solution in PostgreSQL: SELECT name,char_length(name) AS "length" FROM people ORDER BY length DESC;

URI Problem 2742 Solution Richard's Multiverse - URI Online Judge Solution

URI Online Judge Solution 2742 Richard's Multiverse Using PostgreSQL Query Language.  Richard is a famous scientist because of his multiverse theory, where he describes every hypothetical set of parallel universes by means of a database. Thanks to that you now have a job..  As your first task, you must select every Richard from dimensions C875 and C774, together with its existence probability (the famous factor N) with three decimal places of precision.  Remember that the N factor is calculated by multiplying the omega value by 1,618. The data must be sorted by the least omega value. Schema dimensions Column Type id (PK) numeric name varchar   life_registry Column Type id (PK) numeric name varchar omega numeric dimensions_id (FK) numeric Tables dimensions id name 1 C774 2 C784 3 C794 4 C824 5 C875   life_registry id name omega dimensions_id 1 Richard Postman 5.6 2 2 Simple Jelly 1.4 1 3 Richard Gran Master 2.5 1 4 Richard Turing 6.4 4 5 Richard Strall 1.0 3 Output Sample name The N

URI Problem 2741 Solution Students Grades - URI Online Judge Solution

URI Online Judge Solution 2741 Students Grades Using PostgreSQL Query Language.   The semester is over at South Transylvania University. Every grade was closed, and only Alchemy 104 haven’t published its list of approved students.  Therefore, you should show the word 'Approved: ' alongisde the the name of a student and the grade, for those who have been approved (grade ≥7).  Remember to sort the list by grade (higher grades first). Schema students Column Type id (PK) integer name varchar grade numeric Tables students id name grade 1 Terry B. Padilla 7.3 2 William S. Ray 0.6 3 Barbara A. Gongora 5.2 4 Julie B. Manzer 6.7 5 Teresa J. Axtell 4.6 6 Ben M. Dantzler 9.6 Output Sample name grade Approved: Ben M. Dantzler 9.6 Approved: Terry B. Padilla 7.3 URI 2741 Solution in PostgreSQL: SELECT CONCAT('Approved: ',name) AS "name",grade FROM Students WHERE grade>=7 ORDER BY grade DESC