Solution technique of 10684- The jckpot

Problem Description
source: https://uva.onlinejudge.org/external/106/10684.html

Solving Technique:

This is a maximum subarray summation related problem. We have to find the maximum subarray from a one-dimensional array and sum-up all values of sub array then we will get the patterns of consecutive wins that will give maximum benefit and elaborate a win-win strategy.

Using Kadane’s algorithm we can solve in O(n) time.


Kadane’s Algorithm:

image

Solution of 10684- The jckpot

Problem description:
source: https://uva.onlinejudge.org/external/106/10684.html

As Manuel wants to get rich faster and without too much work, he decided to make a career in gambling. Initially, he plans to study the gains and losses of players, so that, he can identify patterns of consecutive wins and elaborate a win-win strategy. But Manuel, as smart as he thinks he is, does not know how to program computers. So he hired you to write programs that will assist him in elaborating his strategy. 

Your first task is to write a program that identifies the maximum possible gain out of a sequence of bets. A bet is an amount of money and is either winning (and this is recorded as a positive value), or losing (and this is recorded as a negative value).

image

Solution technique of UVA problem 727 Equqtion

Problem description:

Write a program that changes an infix expression to a postfix expression according to the following specifications.

 Input condition:

  1.  The infix expression to be converted is in the input file in the format of one character per line, with a maximum of 50 lines in the file. For example, (3+2)*5 would be in the form: ( 3 + 2 ) * 5 
  2.  The input starts with an integer on a line by itself indicating the number of test cases. Several infix expressions follows, preceded by a blank line. 
  3.  The program will only be designed to handle the binary operators +, -, *, /. 
  4.  The operands will be one digit numerals. 
  5. The operators * and / have the highest priority. The operators + and - have the lowest priority. Operators at the same precedence level associate from left to right. Parentheses act as grouping symbols that over-ride the operator priorities. 
  6.  Each testcase will be an expression with valid syntax
image

UVA solution 727 Equation

Problem description:
source: https://uva.onlinejudge.org/external/7/727.html

Write a program that changes an infix expression to a postfix expression according to the following specifications.

 Input condition:

  1.  The infix expression to be converted is in the input file in the format of one character per line, with a maximum of 50 lines in the file. For example, (3+2)*5 would be in the form: ( 3 + 2 ) * 5 
  2.  The input starts with an integer on a line by itself indicating the number of test cases. Several infix expressions follows, preceded by a blank line. 
  3.  The program will only be designed to handle the binary operators +, -, *, /. 
  4.  The operands will be one digit numerals. 
  5. The operators * and / have the highest priority. The operators + and - have the lowest priority. Operators at the same precedence level associate from left to right. Parentheses act as grouping symbols that over-ride the operator priorities. 
  6.  Each testcase will be an expression with valid syntax
image

Solution of 10127 - Ones

Problem description:
source: https://uva.onlinejudge.org/external/101/10127.html


Given any integer 0 n 10000 not divisible by 2 or 5, some multiple of n is a number which in decimal notation is a sequence of 1’s. How many digits are in the smallest such a multiple of n?

Input

A fle of integers at one integer per line.

Output

Solution of 12895 - Armstrong Number

Problem description 
source: https://uva.onlinejudge.org/external/128/12895.html




Input 

The first line of input is an integer, T that determines the number of test cases. Each of the next T lines contain a positive integer N, where N ≤ 1000000000.

Algorithm of 12608 - Garbage Collection

Problem Description Link
Algorithm
This is a simple problem this problem you can solve easily . To solve this problem you must remember 3 conditions.
Garbage truck is collecting garbage on its route starting at the dump and collecting garbage from pick up points in order (closest first). Garbage truck returns to the dump and empties its contents if it either
  1. is full or
  2. cannot load the garbage at the current point because it will put the load over the weight limit (the truck driver has no way of knowing the weight of the garbage at a particular pick up point until the truck reaches that point) or
  3. there are no more pick up points left

12608 - Garbage Collection

Problem Descriptin
source:https://uva.onlinejudge.org/external/126/12608.html



Garbage truck is collecting garbage on its route starting at the dump and collecting garbage from pick up points in order (closest first). Garbage truck returns to the dump and empties its contents if it either 
  1. is full or 
  2.  cannnot load the garbage at the current point because it will put the load over the weight limit (the truck driver has no way of knowing the weight of the garbage at a particular pick up point until the truck reaches that point) or 
  3. there are no more pick up points left 

Solution of 12578 - 10:6:2

Problem Description
source: https://uva.onlinejudge.org/external/125/12578.html

The national flag of Bangladesh is bottle green in color and rectangular in size with the length (L) to width ratio of 10:6. It bears a red circle on the background of green. It maintains the length (L) to radius ratio of 5:1 (If the length is 10 then width should be 6 and radius should be 2). The color in the background represents the greenery of Bangladesh while the red circle symbolizes the rising sun and the sacrifice of lives in our freedom fight. 

Input 

Algorithm of 12405 - Scarecrow

Problem Description Link
Algorithm:
This is a easy problem just you get a string
scan each character until length of string
if character is '.' then replace the next character by '#'  and
increase the counter value and set position=position+2;
some input/output:
image