CF471C.MUH and House of Cards

普及+/提高

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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 using exactly n cards.

北极熊门什科夫和乌斯拉达来自圣彼得堡动物园,大象霍勒斯来自基辅动物园,他们决定建造一座纸牌屋。为此,他们已经找到了一副包含 nn 张扑克牌的厚实牌组。下面描述他们想要建造的纸牌屋结构:

  1. 纸牌屋由若干(非零)层组成。
  2. 每一层由若干(非零)个“房间”和一个“天花板”构成。一个房间由两张互相倾斜支撑的牌组成;房间排成一行,每两个相邻房间共用一张作为“天花板”的牌。
  3. 除最底层外,每一层的房间数必须严格少于其下一层的房间数。

请注意:纸牌屋可以以拥有多个房间的一层作为顶层,此时这些房间也必须被天花板覆盖。此外,相邻两层的房间数之差不一定为 11,该差值可以更大。

当两只熊练习搭牌时,大象霍勒斯试图算出他们的纸牌屋应有多少层。纸牌屋的“高度”即为其层数。对于给定的 nn 张牌,可能可以搭建出多种不同高度的纸牌屋。看起来大象无法解决这个问题,因此他请你计算:恰好使用 nn 张牌所能搭建出的不同高度(即不同层数)的纸牌屋一共有多少种。

输入格式

The single line contains integer n (1 ≤ n ≤ 1012) — the number of cards.

单行包含一个整数 nn(1 ≤ n ≤ 10121 \leq n \leq 10^{12})——卡片的数量。

输出格式

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

输出由恰好 n 张卡片搭建的房子所能具有的不同高度的数量。

输入输出样例

  • 输入#1

    13

    输出#1

    1
  • 输入#2

    6

    输出#2

    0

说明/提示

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.

在第一个样例中,你只能建造如下这两栋房子(注意:你必须使用全部卡片):

因此,13 张卡片仅够建造两层高的房子,答案为 1。

第二个样例中的六张卡片不足以建造任何房子。

输入解题思路,AI测评打分。不知道怎么写?

首页