Codeforces Round #280 (Div. 2)A. Vanya and Cubes(简单计算)
来源:互联网 发布:js全栈开发教程 编辑:程序博客网 时间:2024/06/05 19:37
题目链接
题意:搭积木,告诉你第i层需要i*(i+1)/2个,然后给你总数n个,问你可以搭几层
题解:直接计算
#define CF#ifndef CF#include<cstdio>#include<algorithm>#include<cstring>#include<cmath>#include<string>#include<iostream>#include<set>#include<vector>#else#include<bits/stdc++.h>#endif // CFusing namespace std;#define LL long long#define pb push_back#define X first#define Y second#define cl(a,b) memset(a,b,sizeof(a))typedef pair<long long ,long long > P;const int maxn=100005;const LL inf=1LL<<60;const LL mod=1e9+7;int main(){ int n;scanf("%d",&n); int ans=0,i=1,sum=0; while(true){ sum+=i*(i+1)/2; if(sum>n){ printf("%d\n",i-1); return 0; } i++; } return 0;}
0 0
- Codeforces Round #280 (Div. 2)A. Vanya and Cubes(简单计算)
- Codeforces Round #280 (Div. 2)---A. Vanya and Cubes (规律 + 暴力)
- A. Vanya and Table(Codeforces Round #308 (Div. 2))
- (Vanya and Lanterns)Codeforces Round #280 (Div. 2)B
- Vanya and Lanterns( Codeforces Round #280 (Div. 2)B)
- Codeforces Round #235 (Div. 2) A. Vanya and Cards
- Codeforces Round #308 (Div. 2) A. Vanya and Table
- Codeforces Round #355 (Div. 2) A. Vanya and Fence(水题)
- Codeforces Round #355 (Div. 2) A. Vanya and Fence (水题)
- Codeforces Round #280 (Div. 2) E. Vanya and Field
- Codeforces Round #280 (Div. 2) C. Vanya and Exams
- Codeforces Round #280 (Div. 2)_C. Vanya and Exams
- Codeforces Round #280 (Div. 2)-D. Vanya and Computer Game
- B. Vanya and Books(Codeforces Round #308 (Div. 2))
- C. Vanya and Scales(Codeforces Round #308 (Div. 2))
- D. Vanya and Triangles(Codeforces Round #308 (Div. 2))
- E. Vanya and Brackets(Codeforces Round #308 (Div. 2))
- CodeForces 492A Vanya and Cubes(水题)
- 自己实现的字符串操作函数
- HMM学习笔记1
- ARM+llinux系统移植3G拨号上网收发短信(二)
- Maven学习总结(三)——使用Maven构建项目
- 在一个多线程系统中,主进程应该写什么?
- Codeforces Round #280 (Div. 2)A. Vanya and Cubes(简单计算)
- Maven学习总结(四)——Maven核心概念
- MVC中处理Json和JS中处理Json对象
- 聚合数据网站
- “数据结构与算法”有点难
- 完美解决 input密码提示功能
- C语言实现的环形队列
- LeetCode 152 Maximum Product Subarray
- CSS中的长度单位,宽度自适