Re: 10523 - Very Easy
Posted: Tue Mar 04, 2014 3:11 pm
So, those who're completely stuck, here are some hints that I'd like to share as I solved the problem. Note that as the numbering of the hints increases, the problem should get easier to solve. So, bear this in mind and read as much - or as little as you need to.
Hint #1
First, notice the the expansion for one the sample inputs provided
Input:
Expansion:
Note that the "x" stands for "times" - the multiplication symbol. Not the letter "x".
Hint #2
More generally, using lower-case "a" instead of upper-case "A" (which is plain weird to use) this can be written out as
See if it's possible to reduce this formula.
Hint #3
Let
Multiplying by a on both sides, we have
Now, subtracting ay from y we have
Note that dividing both sides by (1 - a), gives us y - which is what we're after. Try to see if it's possible to find a formula for
Hint #4
Let
Dividing by a on both sides we have
Subtracting this amount from z, we have
Now,
Find out z in terms of a and n and replace this in what was given at the end of Hint #3.
Hint #1
First, notice the the expansion for one the sample inputs provided
Input:
Code: Select all
3 3
Code: Select all
1 x 3^1 + 2 x 3^2 + 3 x 3^3 = 3 + 18 + 81 = 102
Hint #2
More generally, using lower-case "a" instead of upper-case "A" (which is plain weird to use) this can be written out as
Code: Select all
a + 2 x a^2 + 3 x a^3 + ... + n x a^n
Hint #3
Let
Code: Select all
y = a + 2 x a^2 + 3 x a^3 + ... + n x a^n
Code: Select all
ay = a x (a + 2 x a^2 + 3 x a^3 + ... + n x a^n)
ay = a^2 + 2 x a^3 + 3 x a^4 + ... + (n - 1) x a^n + n x a^(n + 1)
Code: Select all
y - ay = (a + 2 x a^2 + 3 x a^3 + ... + n x a^n ) - (a^2 + 2 x a^3 + 3 x a^4 + ... + (n - 1) x a^n + n x a^(n + 1))
y - ay = a + (2 x a^2 - a^2) + (3 x a^3 - 2 x a^3) + ... + (n x a^n - (n - 1) x a^n) - n x a^(n + 1)
y (1 - a) = (a + a^2 + a^3 + ... + a^n) - n x a^(n + 1)
Code: Select all
a + a^2 + a^3 + ... + a^n
Let
Code: Select all
z = a + a^2 + a^3 + ... + a^n
Code: Select all
z / a = 1 + a + a^2 + ... + a^(n - 1)
Code: Select all
z - (z / a) = a + a^2 + a^3 + ... + a^n - (1 + a + a^2 + ... + a^(n - 1)) = a^n - 1
Code: Select all
z(1 - 1/a) = a^n -1