C. MUH and House of Cards
 

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 usingexactly n 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 test(s)
input
13
output
1
input
6
output
0
Note

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.

算是找规律吧、注意用long long

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <ctime>
#include <vector>
using namespace std;
#define INF 0x3f3f3f3f
#define ll long long
#define N 200010 int main()
{
ll n;
ll cnt;
while(scanf("%lld",&n)!=EOF)
{
cnt=;
for(ll k=;;k++)
{
ll Min=(ll)(*k*k+k)/;
if(Min>n) break;
if((n-Min)%==) cnt++;
}
printf("%lld\n",cnt);
}
return ;
}

[CF 471C] MUH and House of Cards的更多相关文章

  1. CodeForces 471C MUH and House of Cards

    MUH and House of Cards Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & % ...

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

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

  3. CF数据结构练习

    1. CF 438D The Child and Sequence 大意: n元素序列, m个操作: 1,询问区间和. 2,区间对m取模. 3,单点修改 维护最大值, 取模时暴力对所有>m的数取 ...

  4. CF 204B Little Elephant and Cards

    题目链接: 传送门 Little Elephant and Cards time limit per test:2 second     memory limit per test:256 megab ...

  5. CF Soldier and Cards (模拟)

    Soldier and Cards time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...

  6. cf 546C Soldier and Cards

    题目链接:C. Soldier and Cards Two bored soldiers are playing card war. Their card deck consists of exact ...

  7. cf B George and Cards

    题意:给你一个只有‘.’和'#'的n*n的格子,问所有的'#'是不是只属于一个十字叉,如果不是输出NO,否则输出YES. #include <cstdio> #include <cs ...

  8. cf E. George and Cards

    http://codeforces.com/contest/387/problem/E 题意:给你n个数,然后在输入k个数,这k个数都在n个数中出现,进行每一次操作就是在n个数中选择长度为w的连续序列 ...

  9. Solution -「CF 1392H」ZS Shuffles Cards

    \(\mathcal{Description}\)   Link.   打乱的 \(n\) 张编号 \(1\sim n\) 的数字排和 \(m\) 张鬼牌.随机抽牌,若抽到数字,将数字加入集合 \(S ...

随机推荐

  1. Spark小课堂Week2 Hello Streaming

    Spark小课堂Week2 Hello Streaming 我们是怎么进行数据处理的? 批量方式处理 目前最常采用的是批量方式处理,指非工作时间运行,定时或者事件触发.这种方式的好处是逻辑简单,不影响 ...

  2. 【转】 GDB 常用调试方法

    一.多线程调试 多线程调试可能是问得最多的.其实,重要就是下面几个命令: info thread 查看当前进程的线程. thread <ID> 切换调试的线程为指定ID的线程. break ...

  3. linux源码分析2

    linux源码分析 这里使用的linux版本是4.8,x86体系. 这篇是 http://home.ustc.edu.cn/~boj/courses/linux_kernel/1_boot.html  ...

  4. 3123 高精度练习之超大整数乘法 - Wikioi

    题目描述 Description 给出两个正整数A和B,计算A*B的值.保证A和B的位数不超过100000位. 输入描述 Input Description 读入两个用空格隔开的正整数 输出描述 Ou ...

  5. jQuery列表拖动排列-jquery list dragsort插件参数和使用方法

    在编写网页的时候,有时可能需要对ul的li进行排序,今天就给大家推荐使用jquery插件jquery list dragsort实现列表拖动排序效果. 效果如图: jquery list dragso ...

  6. Delphi逆向

    Delphi反汇编内部字符串处理函数/过程不完全列表 名称 参数 返回值 作用 等价形式 / 备注 _PStrCat EAX :目标字符串 EDX :源字符串 EAX 连接两个 Pascal 字符串 ...

  7. HTML可编辑下拉框

    <div style="position:relative;">   <select style="width:120px;" onchang ...

  8. smarty foreach 最全用法

    <?php$search_condition = "where name like '$foo%' ";$sql = 'select contact_id, name, ni ...

  9. hdu 4101

    比赛的时候先是受以前一个圣神海的题目 用了两遍DFS 第一遍标记出围墙  第二遍求围墙外和每块围墙降为1所需的攻击次数  结果爆栈  改为BFS后AC DFS的加了一句这个 #pragma comme ...

  10. 使用Web代理实现Ajax跨域

    目前的工作项目分为前端和后台,双方事先约定接口,之后独立开发.后台每天开发完后在测试服务器上部署,前端连接测试服务器进行数据交互.前端和后台分开的好处是代码不用混在一个工程里一起build,互不干涉. ...