Codeforces 471C MUH and House of Cards

Source: Internet
Author: User

MUH and House of CardsTime limit:1000MS Memory Limit:262144KB 64bit IO Format:%i64d &%i6 4u SubmitStatusPracticecodeforces 471C

Description

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 usingexactlyn 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 Input

Input
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#include <stdio.h>2 3 intMain ()4 {5     Long LongN,num;6     Long Longi,j;7      while(SCANF ("%i64d", &n)! =EOF)8     {9num=0;Ten          for(i=0;; i++) One         { A             Long LongX= (2* (i+1) * (i+2))/2+ (i* (i+1))/2, y; -             //printf ("%i64d\n", x); -             if(n>=x) they=n-x; -             Else -                  Break; -             if(y%3==0) +num++; -         } +printf"%i64d\n", num); A     } at     return 0; -}
View Code

Codeforces 471C 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.