CodeForces 471C MUH and House of Cards
来源:互联网 发布:最新中国省市区数据库 编辑:程序博客网 时间:2024/06/06 18:25
CodeForces 471C MUH and House of Cards
Time Limit:1000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u
Description
Polar bears Menshykov and Uslada from the zoo of St. Petersburg and elephant Horace from the zoo of 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. A room is two cards that are leaned towards each other. The rooms are made in a row, each two 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 may end by the floor with more than one room, and in this case they also must be covered by the ceiling. Also, the number of rooms on the adjoining floors doesn't have to differ by one, the difference may be more.
While bears are practicing to put cards, Horace tries to figure out how many floors their house should consist of. The height of the house is the number of floors in it. It is possible that 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 houses that they can make usingexactlyn cards.
Input
The single line contains integer n (1 ≤ n ≤ 1012) — the number of cards.
Output
Print the number of distinct heights that the houses made of exactly n cards can have.
Sample Input
13
1
6
0
Hint
In the first sample you can build only these two houses (remember, you must use all the cards):
Thus, 13 cards are enough only for two floor houses, so the answer is 1.
The six cards in the second sample are not enough to build any house.
#include<stdio.h>int main() {long long int i,j,n;while(scanf("%lld",&n)!=EOF){i=0;j=2;for(;n-j>=0;j+=3) {n-=j;if(n%3==0){i++;}}printf("%lld\n",i);}return 0;}
- codeforces 471C MUH and House of Cards 数论
- CodeForces 471C - MUH and House of Cards(推导)
- CodeForces 471C MUH and House of Cards
- CodeForces 471C MUH and House of Cards
- CodeForces 471C MUH and House of Cards
- CodeForces 471C MUH and House of Cards
- CodeForces 471C MUH and House of Cards
- C. MUH and House of Cards(Codeforces Round #269)
- Codeforces 471C MUH and House of Cards【找规律+二分】
- Codeforces #269 (Div. 2)C. MUH and House of Cards(数学:通项公式)
- Codeforces Round #269 (Div. 2) C MUH and House of Cards 爆搜+剪枝
- CF 269C MUH and House of Cards
- C. MUH and House of Cards(数论规律题)
- C. MUH and House of Cards (题目类型很有特点,存一下以便学习)
- MUH and House of Card
- CodeForces 471B MUH and Important Things
- Codeforces 471B MUH and Important Things
- CodeForces 471D MUH and Cube Walls
- 某某业务数据库RMAN备份实例记录
- iOS-Ios8 Xcode6 设置Launch Image 启动图片
- 设计模式笔记--中介者模式
- mysql悲观锁总结和实践
- php操作mysql
- CodeForces 471C MUH and House of Cards
- 2015移动开发之iOS回顾
- Visual Studio下实现Eigen+Intel MKL的矩阵乘法
- MyEclispe点击add deploment 无反应的处理
- C#ref 使用
- VC通过套接字获取IP地址和MAC地址程序(转载)
- 美国海军的事后回顾
- Android 中的SIP协议
- JAVA字符串