Cquoj 10819 MUH and House of Cards

Source: Internet
Author: User

Polar Bears Menshykov and Uslada from the zoo of St. Petersburg and Elephant Horace from the zoo's Kiev decided to build A House of Cards. For that they ' ve already found a hefty deck of n playing cards. Let's describe the house they want to make:

    1. The house consists of some non-zero number of floors.
    2. Each floor consists of a non-zero number of rooms and the ceiling. The A-cards is the leaned towards each of the other. The rooms is made in a row with each of the adjoining rooms share a ceiling made by another card.
    3. Each floor besides for the lowest one should contain less rooms than the floor below.

Please note that the House could end by the than one and the They also must is covered by The ceiling. Also, the number of rooms on the adjoining floors doesn ' t has to differ by one, the difference is more.

While bears is practicing to put cards, Horace tries to figure out how many floors their house should consist of. The height of the house was the number of floors in it. It is possible so you can make a lot of different houses of different heights out of n cards. It seems that the elephant cannot solve this problem and he asks you to count the number of the distinct heights of the Ho Uses that they can make using exactly n cards.

Input

The single line contains integer n (1≤ n ≤10)-the number of cards.

Output

Print the number of distinct heights that the houses made of exactly n cards can has.

Sample Inputinput
13
Output
1
Input
6
Output
0
Hint

The first sample can build only these and houses (remember, you must with all the cards):

Thus, cards was enough only for the floor houses, so the answer is 1.

The six cards in the second is not a enough to build no house.

1 /*2 April 24, 2016 14:55:303 4 This topic to see Ah to the N cards, to build the number of different floors of the house5 6 look at the hint graphics of the topic and know test instructions.7 Look at the graph and you'll see8 (this figure is not the graph given by the title, but the first layer of 2 cards, the second layer 5 cards ...),9 the number of cards required for the nth layer (top down) is 2 * n + (n-1),Ten You can simplify the formula is 3 * n-1, so you will find One  A The number of cards required for each layer 1 is a multiple of 3, - then each layer is 1, if there is an I layer, then actually is poor I -  the So, suppose that a total card x, is actually enumerated I, how many I make (x + i)%3 = = 0, - (The meaning here is if I meet (x + i)% 3 = = 0, - You can build the house of layer I (because the number of cards on each floor is the difference of 1 is a multiple of 3) - think about it and you know it.) +  - But there is a limit, because I need to build a minimum number of cards to know, + cannot exceed the number of cards given, X-sheets, A by the linear formula (2 + (3*i-1)) * I/2 = (3 * i + 1) * I/2 available at Building layer I requires at least (3 * i + 1) * I/2 card, so it is easy to determine the scope of the enumeration, - and the answer is small, so it's okay to enumerate answers directly -  - */ -  -# include <iostream> in# include <cstdio> -# include <cstring> to# include <algorithm> +# include <queue> -# include <vector> the# include <cmath> *# define LLLong Long  $# define INF0x3f3f3f3fPanax Notoginseng using namespacestd; -  the intMainvoid) + { A LL N, i, ans; the       while(~SCANF ("%i64d", &N)) { +Ans =0; -           for(i =1; ; i++){ $              if(N < (3* i +1) * I/2) $                   Break; -              if((n + i)%3==0) -ans++; the          } -printf"%i64d\n", ans);Wuyi      } the      -     return 0;  Wu}

Cquoj 10819 MUH and House of Cards

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.