Problem J1: What is n, Daddy?

Natalie is learning to count on her fingers. When her Daddy tells her a number n, she asks “What is n, Daddy?”, by which she means “How many fingers should I hold up on each hand so that the total is n?” To make matters simple, her Daddy gives her the correct finger representation according to the following rules:

• the number may be represented on one or two hands;
• if the number is represented on two hands, the larger number is given first.

• 4 is 4.
• 4 is 3 and 1.
• 4 is 2 and 2.

Input Format

A single integer n (1 ≤ n ≤ 10).

Output Format

The output is the number of ways of producing that number on two hands, subject to the rules outlined above.

`4`

Sample Output

`3`

Point Value: 3
Time Limit: 2.00s
Memory Limit: 16M

Languages Allowed:
C++03, PAS, C, HASK, ASM, RUBY, PYTH2, JAVA, PHP, SCM, CAML, PERL, C#, C++11, PYTH3

• (0/0)
Something is obviously wrong with my code... can you tell me what's wrong??

It would be much appreciated!!

• (1/0)
You aren't printing the right answers. Remember that 4 on the left hand and 2 on the right is the same as 2 on the left hand and 4 on the right

• (0/0)
Why is it marking me wrong when I say that you can only make 7 4 times? The combinations are clear! 0 and 7, 1, and 6, 2 and 5, 3 and 4!! Is there something wrong with the format that I am putting it in or something?

Thanks!

• (9/0)
Do you have 7 fingers on your right hand? :^)

• (1/0)
ohhhhhhhhhhhh.... ok.... thanks!!!

• (0/0)
Can you give me a hint for problem ccc10j1.

• (11/1)
Although the problem suggests using fingers to count I found that using my toes was more effective.

• (1/0)
So to solve this question all you have to do is use your hands and do the math yourself and program the thing to output your pre-thought of answer? I was thinking of some complicated way involving loops and stuff.

• (1/0)
There are ways to do this that do not involve precomputation or brute force. Now that you've solved the problem, you can see them.

See zhxl0903's solution for an example of a formula that works for human hands, or HelloMelloC's solution for an example of a more generalisable solution involving loops.

• (1/0)
I used two different ways and one of them is brute force. Both did not work. I have no idea why, its very easy and my answers were right but it said 'wrong answer'. Does it have to do with the peg servers?

• (2/1)
Your output is wrong. This problem is quite simple since you can try it with your own hands. How many different ways can you represent 10 for example, with your hands?

• (1/0)
oh, now I get it... thanks for the help

• (1/0)
Can this be solved without "Brute force"?
(by putting the input into an equation)

• (1/0)
Absolutely.

• (1/0)
Would that method be faster or slower (runtime) compared to bruteforce ?

• (3/1)
Nothing can be slower than brute force.

• (3/0)

• (1/0)
though, admittedly, some problems must be solved with brute force, but efficiently implemented (cryptcow comes to mind); see also bogosort

• (2/0)
What is cryptcow? I didn't get much out of a google search o.O

• (1/0)
It's just a problem from the USACO Training Webpages (http://train.usaco.org).

• (1/0)
how comes there no description? bug...

• (1/0)
I'll put up problem descriptions eventually; for now I'm too lazy. You can find the original problem description at the CEMC website; just remember that input/output are not to be read from / written to files, and that you should not prompt.