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:
- The house consists of some non-zero number of floors.
- 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.
- 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