CodeForces 492A Vanya and Cubes
1 second
256 megabytes
standard input
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.
The first line contains integer n (1 ≤ n ≤ 104) — the number of cubes given to Vanya.
Print the maximum possible height of the pyramid in the single line.
1
1
25
4
Illustration to the second sample:
水题、
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1e9;
const double eps = 1e-;
int cas = ; int main()
{
#ifdef LOCAL
// freopen("case.txt","r",stdin);
#endif
int n,ans,sum,sum2;
while(cin>>n)
{
ans = sum = sum2 = ;
while(true)
{
if(sum2 > n) break;
ans ++ ;
sum += ans;
sum2 += sum;
}
cout << ans- << endl;
}
return ;
}
CodeForces 492A Vanya and Cubes的更多相关文章
- 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 ...
- cf492A Vanya and Cubes
A. Vanya and Cubes time limit per test 1 second memory limit per test 256 megabytes input standard i ...
- codeforces 492E. Vanya and Field(exgcd求逆元)
题目链接:codeforces 492e vanya and field 留个扩展gcd求逆元的板子. 设i,j为每颗苹果树的位置,因为gcd(n,dx) = 1,gcd(n,dy) = 1,所以当走 ...
- Codeforces 677D Vanya and Treasure 暴力+BFS
链接 Codeforces 677D Vanya and Treasure 题意 n*m中有p个type,经过了任意一个 type=i 的各自才能打开 type=i+1 的钥匙,最初有type=1的钥 ...
- CodeForces 552C Vanya and Scales
Vanya and Scales Time Limit:1000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u S ...
- Codeforces 677C. Vanya and Label 位操作
C. Vanya and Label time limit per test:1 second memory limit per test:256 megabytes input:standard i ...
- CodeForces - 552E Vanya and Brackets
Vanya and Brackets Time Limit: 1000MS Memory Limit: 262144KB 64bit IO Format: %I64d & %I64u ...
- codeforces C. Vanya and Scales
C. Vanya and Scales Vanya has a scales for weighing loads and weights of masses w0, w1, w2, ..., w10 ...
- codeforces 492B. Vanya and Lanterns 解题报告
题目链接:http://codeforces.com/problemset/problem/492/B #include <cstdio> #include <cstdlib> ...
随机推荐
- 《python基础教程(第二版)》学习笔记 字符串(第3章)
<python基础教程(第二版)>学习笔记 字符串(第3章)所有的基本的序列操作(索引,分片,乘法,判断成员资格,求长度,求最大最小值)对字符串也适用.字符串是不可以改变的:格式化输出字符 ...
- Eclipse debug neutron-server
1 首先停掉neutron-server kill neutron-server in screen by ctr-c q-svc 2 cp /usr/local/bin/neutron-server ...
- HDU 4034 Graph:反向floyd
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4034 题意: 有一个有向图,n个节点.给出两两节点之间的最短路长度,问你原图至少有多少条边. 如果无解 ...
- web项目路径如何更改
- nodejs stream & buffer 互相转换
stream 转 buffer function streamToBuffer(stream) { return new Promise((resolve, reject) => { let b ...
- 截取URL参数的方法
1,有点小瑕疵,双问号会截取不到第一个参数 function GetQueryString(name){ var reg = new RegExp("(^|&)"+ nam ...
- Java IO 简记
1.File 类: l java.io.File类:文件和目录路径名的抽象表示形式,与平台无关 l File 能新建.删除.重命名文件和目录,但 File 不能访问文件内容本身.如果需要访问文件内 ...
- visual studio tools for unity代码提示快捷键
visual studio tools for unity代码提示快捷键 ctrl+ shift +q
- perl: warning: Falling back to the standard locale ("C").
/********************************************************************************** * perl: warning: ...
- HDU3037Saving Beans(组合数+lucas定理)
Problem Description Although winter is far away, squirrels have to work day and night to save beans. ...