CCC '10 J1 - What is n, Daddy?

View as PDF

Submit solution

Points: 3
Time limit: 2.0s
Memory limit: 64M

Problem type
Canadian Computing Competition: 2010 Stage 1, Junior #1

Natalie is learning to count on her fingers. When her Daddy tells her a number n (1 \le n \le 10), 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.

For example, if Natalie asks "What is 4, Daddy?", her Dad may reply:

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

Your job is to make sure that Natalie's Daddy gives the correct number of answers.

Input Specification

The input will be a single integer i such that 1 \le i \le 10.

Output Specification

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

Sample Input

4

Output for Sample Input

3

Comments


  • 2
    Marshmellon  commented on March 9, 2021, 8:39 a.m.

    Can't you just use a 10 branch if statement for all the number of fingers.


    • 0
      Lego1024  commented on April 3, 2021, 4:17 a.m.

      Yes, you may:)


  • -5
    iiGam_r  commented on Jan. 16, 2021, 5:06 p.m.

    This comment is hidden due to too much negative feedback. Click here to view it.


  • -5
    EthanFanPython3  commented on Oct. 31, 2020, 7:03 a.m.

    This comment is hidden due to too much negative feedback. Click here to view it.


  • -1
    alexshao  commented on Sept. 23, 2020, 12:00 p.m. edited

    Child: What is n, daddy?

    Daddy: Hurh.


  • 0
    devarshi  commented on May 12, 2020, 11:20 p.m.

    Would you show 5 on the right hand and then on the left? Does that count as 1 possibility?


    • 3
      hjanday  commented on May 13, 2020, 10:28 a.m.

      Any duplicate cases would only be counted once.


  • 6
    alihu264  commented on April 26, 2020, 8:48 p.m.

    how did I get stumped for 20 minutes on a 3 pointer


  • 3
    jorispos  commented on Feb. 19, 2019, 6:32 p.m.

    Can anyone check my solution? Is there any other (maybe mathematical) way to solve this?


    • 5
      kingW3  commented on Feb. 19, 2019, 7:02 p.m.

      If you're looking for more mathematical solution try thinking about the same problem but make the number of fingers also a parameter. Instead of it being 5 and make n\leq2k.


  • 0
    Deathheart270  commented on Jan. 30, 2019, 12:05 p.m. edited

    Oh we only have 5 fingers lol.


  • 114
    CarolChen  commented on Feb. 15, 2016, 11:55 a.m. edited

    Could not figure out what I was doing wrong then I remembered we have only 5 fingers.


    • 4
      Leaderleade  commented on Aug. 29, 2020, 11:54 a.m.

      well, that's what struck me30 min: Max fingers number - 5 important hint


    • 6
      MakanDey  commented on Feb. 22, 2018, 11:29 a.m.

      Oh darn I thought I had 40.


    • 4
      retronerd2016  commented on Nov. 2, 2017, 5:52 p.m.

      wait hold on the example says 3, what does 3 mean


      • -4
        aaronsenu  commented on Aug. 11, 2020, 11:34 p.m. edit 3

        3


      • 13
        xxsc  commented on July 3, 2018, 11:19 p.m. edited

        3 is the number of ways to show 4.

        4 is 4 is one way.

        4 is 3 and 1 is another.

        4 is 2 and 2 is the last one, because saying 4 is 1 and 3 would be the same as saying 4 is 3 and 1. Same goes with 4 is 0 and 4.

        EDIT:

        Yes CarolChen that is helpful.


    • 6
      Alicia  commented on Oct. 31, 2017, 11:59 p.m.

      @ CarolChen that's a very helpful hint, thanks


    • 8
      Epic1Online  commented on Oct. 30, 2017, 4:25 p.m.

      That was a very helpful comment thanks!