A. Vanya and Cubes
time limit per test 1 second
memory limit per test 256 megabytes
input standard input
output standard output

Vanya got n cubes. He decided to build a pyramid from them. Vanya wants to build the pyramid as follows: the top level of the pyramid must consist of 1 cube, the second level must consist of 1 + 2 = 3 cubes, the third level must have 1 + 2 + 3 = 6 cubes, and so on. Thus, the i-th level of the pyramid must have 1 + 2 + ... + (i - 1) + i cubes.

Vanya wants to know what is the maximum height of the pyramid that he can make using the given cubes.

Input

The first line contains integer n (1 ≤ n ≤ 104) — the number of cubes given to Vanya.

Output

Print the maximum possible height of the pyramid in the single line.

Sample test(s)
input
1
output
1
input
25
output
4
Note

Illustration to the second sample:

就是sb模拟了

#include<cstdio>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<ctime>
#define LL long long
#define inf 0x7ffffff
#define pa pair<int,int>
#define pi 3.1415926535897932384626433832795028841971
using namespace std;
inline LL read()
{
LL x=0,f=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
return x*f;
}
int n,tot;
int s[100010];
int main()
{
n=read();
for (int i=1;i<=n;i++)
{
s[i]=s[i-1]+i;
tot+=s[i];
if (tot>n)
{
printf("%d\n",i-1);
return 0;
}
if (tot==n)
{
printf("%d\n",i);
return 0;
}
}
}

cf492A Vanya and Cubes的更多相关文章

  1. Codeforces Round #280 (Div. 2) A. Vanya and Cubes 水题

    A. Vanya and Cubes time limit per test 1 second memory limit per test 256 megabytes input standard i ...

  2. CodeForces 492A Vanya and Cubes

    A. Vanya and Cubes time limit per test 1 second memory limit per test 256 megabytes input standard i ...

  3. Codeforces Round #280 (Div. 2) A B C 暴力 水 贪心

    A. Vanya and Cubes time limit per test 1 second memory limit per test 256 megabytes input standard i ...

  4. CodeForces Round #280 (Div.2)

    A. Vanya and Cubes 题意: 给你n个小方块,现在要搭一个金字塔,金字塔的第i层需要 个小方块,问这n个方块最多搭几层金字塔. 分析: 根据求和公式,有,按照规律直接加就行,直到超过n ...

  5. Codeforces Round #280 (Div. 2) A , B , C

    A. Vanya and Cubes time limit per test 1 second memory limit per test 256 megabytes input standard i ...

  6. codeforces C. Vanya and Scales

    C. Vanya and Scales Vanya has a scales for weighing loads and weights of masses w0, w1, w2, ..., w10 ...

  7. 水泡动画模拟(Marching Cubes)

    Marching Cubes算法是三维离散数据场中提取等值面的经典算法,其主要应用于医学领域的可视化场景,例如CT扫描和MRI扫描的3D重建等. 算法主要的思想是在三维离散数据场中通过线性插值来逼近等 ...

  8. Codeforces525E Anya and Cubes(双向搜索)

    题目 Source http://codeforces.com/contest/525/problem/E Description Anya loves to fold and stick. Toda ...

  9. 数论 - Vanya and Computer Game

    Vanya and his friend Vova play a computer game where they need to destroy n monsters to pass a level ...

随机推荐

  1. PHP中数组转换为XML格式

    最近公司要做一个API接口,输出格式要有JSON与XML格式, 在PHP中,输入JSON直接json_encode就可以,但输出XML没有提供函数,于是决定自己写一个. <?php /** * ...

  2. 【80端口占用】win7下80端口被(Pid=4)占用的解决方法

    亲测可用 通过cmd命令查询占用进程的pid netstat -ano 如果要是tomcat等一般程序占用了端口,一般pid比较大,直接找到相应的pid结束掉进程就行啦. 但是如果pid是4,代表sy ...

  3. js比较两个日期大小

    //比较两个日期大小 function dateCompare(startDate,endDate){ var aStart=startDate.split('-'); //转成成数组,分别为年,月, ...

  4. MFC原创:三层架构01(人事管理系统)DAL

    VC++/MFC Window编程原创教程文件夹 C++课程设计来着.但还没学过数据,也还没理解过三层架构,就把这个作业深化点来做了.尽管要做的这个人事管理系统看起来是挺简单的,无非就是处理员工信息. ...

  5. 使用java连接AD域,验证账号password是否正确

    web项目中有时候客户要求我们使用ad域进行身份确认,不再另外做一套用户管理系统.事实上客户就是仅仅要一套账号能够訪问全部的OA.CRM等办公系统. 这就是第三方验证.一般有AD域,Ldap,Radi ...

  6. 笔记本分享无线Wifi

    两种方法: 一.使用软件分享,如Wifi共享精灵,设置非常简单. 二.开启windows 7的隐藏功能:虚拟WiFi和SoftAP(即虚拟无线AP),就可以让电脑变成无线路由器,实现共享上网,节省网费 ...

  7. web笔记

    application: 在tomcat启动过程,会将所有的应用加载进来,会为每一个应用创建一个application对象.这个对象是唯一.但是所有的web应用是互不影响的. like模糊查询 重定向 ...

  8. javascript 识别移动端设备

    看到一种比较简单的方法,于是就把它记录下来备用吧.最近离职了,房子换了,还有...真是一把心酸,我知道谁活着都不容易,自己也资格把自己的苦水吐给别人,因为别人也过得不容易,所以大多不快都只能闷着,大家 ...

  9. sqlserver中的锁与事务

    以下内容整理自: SQL Server中的锁 SQLSERVER中的元数据锁 SQLSERVER中的锁资源类型 浅谈sqlserver中的事务和锁 锁的分类 1.从数据库角度 独占锁(排它锁 X) 独 ...

  10. SqlServer 不同服务器之间数据库连接、数据库登录、数据传递

    需求:我是本地数据库想纯SQL访问其它服务器上的数据库,而不使用数据库客户端的连接.这里面就想到了数据库link,通过下面的代码进行创建以后,就可以在本地对链接的服务器数据库进行操作了--添加SQLS ...