Combinatorics

Let's take a group of K distinct characters . I want to find number of strings that can be constructed such that:-

1) No 2 consecutive positions in the string contain the same character

2) The odd positions in the string can only contain string from the group of K characters

3) The even positions can contain any characters from a-z

Example :-

1) K = {a,b}
N = 5 (Length of the string)

Result :- 4802

2) K = {a,b,c}
N = 5 (Length of the string)

Result :- 15987

Please help!! :)
Looks like there's another round of chef noobs.

All question, zero effort.

anony12345 (you do realize that you're not fully anonymous here, right?), a good way of getting help in ANY walk of life is to show that you're struggling before asking for help. To struggle, you need to actually try to do something.

If you post code that you've written so far and it's anything more than a bare skeleton, that'll be more likely to get you help.

That said, this is a codechef problem, and I'm pretty sure it's against the spirit (and/or rules) of that site to get help from other people to boost your rank, so... good luck!

-Albatross
Write some code first, and if after doing that you have questions/problems post post the code here.

Simply posting the requirements and expecting others to do the work is likely to get you ignored.
I'll give you a hint so you can write some code:

You could/should use std::string and for loops to "walk through" the elements of the strings.
> k^m * k * (26^n)
¿why the extra k?


> But I cannot figure out how to impose the first condition
say that you are somewhere on the middle, in an even position, so may chose between [a-z], which we may break into two groups: the ones that are in K and the ones that aren't
considering the one to your right you'll have {K-1} * {K-1} + {[a-z]-K} * K options, and the same may be said about the pair that you have to the right.
missing requirement?
if K >2, or 3 (not 100% sure) the answer is infinity. You have a finite expected answer, so the problem is not completely stated. This is tied to N … is N always 5, or user input, or ?? Where did it come from, it appears like magic in the test cases without mention in the problem.

is K a-z or anything in Unicode? If K were made up of stuff not in a-z it matters.
Last edited on
Why is actually writing some code so hard for you to do?
All question, zero effort.

Looks like someone got tired of it all and decided to report the OP.

I can't say I blame whoever did it, even if it was bad form.
Topic archived. No new replies allowed.