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:

  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. 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.
  3. 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

Input
13
Output
1
Input
6
Output
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 n,num;
long long i,j;
while(scanf("%I64d",&n)!=EOF)
{
num=;
for(i=;;i++)
{
long long x=(*(i+)*(i+))/+(i*(i+))/,y;
//printf("%I64d\n",x);
if(n>=x)
y=n-x;
else
break;
if(y%==)
num++;
}
printf("%I64d\n",num);
}
return ;
}

CodeForces 471C MUH and House of Cards的更多相关文章

  1. codeforces 471C.MUH and House of Cards 解题报告

    题目链接:http://codeforces.com/problemset/problem/471/C 题目意思:有 n 张卡,问能做成多少种不同楼层(floor)的 house,注意这 n 张卡都要 ...

  2. [CF 471C] MUH and House of Cards

    C. MUH and House of Cards   Polar bears Menshykov and Uslada from the zoo of St. Petersburg and elep ...

  3. codeforces 471B. MUH and Important Things 解题报告

    题目链接:http://codeforces.com/problemset/problem/471/B 题目意思:有 n 个 tasks,编号依次为 1 - n,每个 task 都有一定的难度值来评估 ...

  4. Codeforces Round #364 (Div. 2)->A. Cards

    A. Cards time limit per test 1 second memory limit per test 256 megabytes input standard input outpu ...

  5. codeforces 680A A. Bear and Five Cards(水题)

    题目链接: A. Bear and Five Cards //#include <bits/stdc++.h> #include <vector> #include <i ...

  6. Codeforces Round #460 D. Karen and Cards

    Description Karen just got home from the supermarket, and is getting ready to go to sleep. After tak ...

  7. [CodeForces 471A] MUH and Sticks

    题目链接:http://codeforces.com/problemset/problem/471/A 题目数据规模1 - 9,可以用一个数组进行计数,减掉出现四次的数,看看还有几个是非零数,有一个就 ...

  8. codeforces 235 div2 A. Vanya and Cards

    Vanya loves playing. He even has a special set of cards to play with. Each card has a single integer ...

  9. CodeForces 471D MUH and Cube Walls -KMP

    Polar bears Menshykov and Uslada from the zoo of St. Petersburg and elephant Horace from the zoo of ...

随机推荐

  1. JavaScript的函数和事件(转)

    一.默认函数 JavaScript提供了一些默认的函数 编码函数escape():将非字母.数字字符转换成ASCII码 译码函数unescape():将ASCII码转换成字母.数字字符 求值函数eva ...

  2. UIViewController卸载过程(ios6.0以后)

    在ios6.0以后,废除了viewWillUnload方法和viewDidUnload方法. 在ios6以后,当收到didReceiveMemoryWarning消息调用之后,程序会自动调用didRe ...

  3. ActiveMQ实现负载均衡+高可用部署方案(转)

    本文转自:http://www.open-open.com/lib/view/open1400126457817.html%20 一.架构和技术介绍 1.简介 ActiveMQ 是Apache出品,最 ...

  4. shell 条件测试语句三种方法

    1.test -f file  2.[ -f file ] 3.[[ -f file ]] [ -f file1 -a -f file2]逻辑与[ -f file1 -o -f file2]逻辑或 [ ...

  5. selenium学习记录

    browser = webdriver.Firefox()browser是一个WebDriver类,常用的方法有 'add_cookie',添加cookie 'back',返回上一页 'close', ...

  6. Linux 的 Crontab 命令运用(转)

    cron来源于希腊单词chronos(意为“时间”),是linux系统下一个自动执行指定任务的程序.例如,你想在每晚睡觉期间创建某些文件或文件夹的备份,就可以用cron来自动执行. 服务的启动和停止 ...

  7. linux的mtd架构分析【转】

    转自:http://blog.csdn.net/column/details/xgbing-linux-mtd.html linux mtd 嵌入式系统的存储有很多不可靠之处.随着使用容量的增大,现在 ...

  8. web.xml完整配置

    <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://java ...

  9. Reverse Linked List II

    /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode ...

  10. GCD 多线程同步

    @property (strong, nonatomic) dispatch_queue_t barrierQueue; _barrieQueue = dispatch_queue_create(&q ...