Minggu, 22 Januari 2017

UVA 11942 - Lumberjack Sequencing

Problem Statement: Lumberjack Sequencing

Explanation

Do a simple checking everytime you got an input to check whether the series ordered or not.

Source Code

Kamis, 19 Januari 2017

SPOJ 7974 - ACPC10A Solution

Problem Statement: What's Next

Explanation

Do a addition and multiplication to decide if the sequence is arithmetic or geometric.

Source Code

Selasa, 17 Januari 2017

UVA 12502 - Three Families Solution

Problem Statement: Three Families

Explanation

Let's do a simple simulation from the problem statement to get a better problem understanding. Family A spent 5 hours and family B spent 4 hours to finish the job, so total hours needed to finish the job is 9 hours. Divide the total hours by 3 and result is 9 / 3 = 3. So normally every family must do 3 hours to finish the job.

Because family A do 5 hours job, it means family A do 5 - 3 = 2 extra hours. Meanwhile family B do 1 extra hours. To calculate money that family A get (2 / (2 + 1)) * 90 = 60.

Source Code

Minggu, 15 Januari 2017

UVA 11875 - Brick Game Solution

Problem Statement: Brick Game

Explanation

Because the input always given in increasing or decreasing order and each teams consists of odd number of players, so the answer is the value in the middle of array.

Source Code

UVA 10469 - To Carry or not to Carry Solution

Problem Statement: To Carry or not to Carry

Explanation

Convert the input to binary and add both binary. Everytime you add a different bit (0 + 1 or 1 + 0) add the decimal value that represent the bit to the result.

Source Code

Sabtu, 14 Januari 2017

UVA 10696 - f91 Solution

Problem Statement: f91

Explanation

Implement the recursion defined in the problem statement.

Source Code

UVA 11805 - Bafana Bafana Solution

Problem Statement: Bafana Bafana

Explanation

Where N is the number of players practicing, K the player that receive the ball first, and P the number of passes that need to be done. Follow these step to find the last player who receive the ball.

  • P = P % N
  • K = K + P
  • K = K % N
  • If K equal 0 then set K to the value of N, else just stick to the current value.
Source Code

Jumat, 13 Januari 2017

UVA 11764 - Jumping Mario Solution

Problem Statement: Jumping Mario

Explanation

Do a comparison everytime you get an input to decide if Mario should do a high or low jump.

Source Code

Selasa, 10 Januari 2017

UVA 11059 - Maximum Product Solution

Problem Statement: Maximum Product

Explanation

Try brute force approach to find all possible product combination and find the maximum value.

Source Code

UVA 11000 - Bee Solution

Problem Statement: Bee

Explanation

Simulate the process to get a better understanding of the problem.

  • Female bees give birth to one male bees.
  • Male bees give birth to one male bees and one female bees.
  • There's an immortal female bee.
From the statement above we can form this equation,
  • m[i] = m[i-1] + f[i-1], number of male equal to number of male and female in previous year.
  • f[i] = m[i-1] + 1, number of female equal to number of male in previous year, and plus one because of female immortal bee.
Source Code

Senin, 09 Januari 2017

UVA 11727 - Cost Cutting Solution

Problem Statement: Cost Cutting

Explanation

Given three integer, output the middle value.

Source Code

UVA 495 - Fibonacci Freeze Solution

Problem Statement: Fibonacci Freeze

Explanation

This is a simple problem find a number inside fibonacci sequence that can be solved easily using top down approach. The main problem here is to dealing with a very large number, this problem can be solved by using Java BigInteger.

Source Code

SPOJ 3410 - SAMER08F Solution

Problem Statement: Feynman

Explanation

Find the pattern and you can solve this problem easily.
if N = 1, Result = 1^2.
if N = 2, Result = 1^2 + 2^2.
if N = 3, Result = 1^2 + 2^2 + 3^2.
if N = 4, Result = 1^2 + 2^2 + 3^2 + 4^2.
and so on.

Source Code

Minggu, 08 Januari 2017

UVA 10773 - Back to Intermediate Math Solution

Problem Statement: Back to Intermediate Math

Explanation

The fastest way to cross the river just aim to reach another end of the river without calculating the stream of the river. Otherwise, the shortest way is a straight line that perpendicular with the riverside. Both fastest way and shortest way can be calculated as follow.

  • Fastest Way = d / u
  • Shortest Way = d / Math.sqrt(u^2 - v^2)
Print "Can't Determine" whenever you get an unreal result (u = 0 or u < v). Also, you cannot determine the difference if v = 0.

Source Code

HackerEarth || Manna's First Name Solution

Problem Page: HackerEarth

Explanation

A simple string checking problem. Don't forget to exclude every "SUVO" inside "SUVOJIT".

Source Code

HackerEarth || Monk Takes a Walk Solution

Problem Page: HackerEarth

Explanation

This problem classified as very easy in linear search category. You need to output the vowel occurence in the given string.

Source Code

UVA 11332 - Summing Digits Solution

Problem Statement: Summing Digits

Explanation

Do a simple digit checking using mod and div until the result only contain a single digit.

Source Code

Jumat, 06 Januari 2017

UVA 10370 - Above Average Solution

Problem Statement: Above Average

Explanation

Calculate the average and find how much people get final grade above average.

Source Code

Kamis, 05 Januari 2017

Rabu, 04 Januari 2017

UVA 1225 - Digit Counting Solution

Problem Statement: Digit Counting

Explanation

Do a brute force approach to solve this problem. Iterate through number 1 to N and count every digit occurence.

Source Code

UVA 11934 - Magic Formula Solution

Problem Statement: Magic Formula

Explanation

Use brute force approach to solve this problem. Try to substitute number from 0  up to L to the quadratic function and check if the value divisible by d or not.

Source Code

UVA 10324 - Zeros and Ones Solution

Problem Statement: Zeros and Ones

Explanation

Iterate through the given range and check whether the range contain same character or not.

Source Code

Senin, 02 Januari 2017

UVA 1585 - Score Solution

Problem Statement: Score

Explanation

Iterate through the string and create a variable for counter. Everytime you get a character X reset the counter to 1, else add the counter to result and increment the counter.

Source Code

UVA 10038 - Jolly Jumpers Solution

Problem Statement: Jolly Jumpers

Explanation

Create an array size of n as a flag that indicate whether a value has been selected or not. The sequence is not jolly everytime you meet this condition.

  • There's a zero difference between adjacent number.
  • Have difference more than or equal n.
  • The same difference exist already.
Source Code

UVA 10071 - Back to High School Physics Solution

Problem Statement: Back to High School Physics

Explanation

Displacement equation, d = v * t. Then multiply it by 2 because the problem asked for the displacement in double of given time.

Source Code



UVA 11461 - Square Numbers Solution

Problem Statement: Square Numbers

Explanation

NumOfSquares = floor(sqrt(b)) - ceil(sqrt(a)) + 1, where b > a.

Source Code

Minggu, 01 Januari 2017

UVA 10963 - The Swallowing Ground Solution

Problem Statement: The Swallowing Ground

Explanation

Calculate whether each gaps have the same length or not and don't forget to add a blank line between two cases.

Source Code

UVA 12405 - Scarecrow Solution

Problem Statement: Scarecrow

Explanation

Iterate through every character in the given string. Everytime you find dot character (.), increment the answer by 1 and increment the iterator by 3 (because every scarecrow can cover 3 space).

Source Code

UVA 11115 - Uncle Jack Solution

Problem Statement: Uncle Jack

Explanation

Big number problem. Use BigInteger and output n^d.

Source Code