CF 280A. Vanya and Cubes(div2)
来源:互联网 发布:jquery 1.10.2.min.js 编辑:程序博客网 时间:2024/06/03 21:59
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<cstring>
#include<algorithm>
#include<cstdlib>
#include<vector>
#include<cmath>
#include<stdlib.h>
#include<iomanip>
#include<list>
#include<deque>
#include<map>
#include <stdio.h>
#include <queue>
#include <stack>
#define maxn 10000+5
#define ull unsigned long long
#define ll long long
#define reP(i,n) for(i=1;i<=n;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define cle(a) memset(a,0,sizeof(a))
#define mod 90001
#define PI 3.141592657
#define INF 1<<30
const ull inf = 1LL << 61;
const double eps=1e-5;
using namespace std;
bool cmp(int a,int b){
return a>b;
}
int t;
int main()
{
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
cin>>t;
int sum=0;
for(int i=1;;i++)
{
sum+=(i*i+i)/2;
if(sum==t){cout<<i<<endl;break;}
if(sum>t){cout<<i-1<<endl;break;}
}
return 0;
}
- CF 280A. Vanya and Cubes(div2)
- Codefroces 280 div2 A. Vanya and Cubes
- A. Vanya and Cubes
- A - Vanya and Cubes
- CF 280B. Vanya and Lanterns(div2)
- CF 280C. Vanya and Exams(div2)
- 492A - Vanya and Cubes
- 492A - Vanya and Cubes
- Codeforces 492A. Vanya and Cubes 水
- Codeforces 492A Vanya and Cubes(水)
- CodeForces 492A Vanya and Cubes
- Codeforces 492A Vanya and Cubes【水题】
- (CF)A. Vanya and Cards
- Vanya and Cubes
- Codeforces Vanya and Cubes
- CF 297 div2 E. Anya and Cubes (hash+dfs)
- Codeforces Round #280 (Div. 2)---A. Vanya and Cubes (规律 + 暴力)
- Codeforces Round #280 (Div. 2)A. Vanya and Cubes(简单计算)
- HDU3336Count the string
- HDU 4707Pet
- CF 253A. Anton and Letters
- CF 253B. Kolya and Tandem Repeat
- cust 学校选拔赛
- CF 280A. Vanya and Cubes(div2)
- CF 280B. Vanya and Lanterns(div2)
- CF 280C. Vanya and Exams(div2)
- C语言qsort的三种使用
- 升级chrome后字体模糊的解决办法
- 学生成绩管理系统(c++)控制台应用程序
- 控制台下画图
- 位运算
- 计算机中的负数