Codeforces 492A - Vanya and Cubes (求和公式)
2017-07-18 11:13
519 查看
感觉很简单但是错了几次
解题说明:水题一道,熟悉通项公式求和即可。
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
int a[100101],b[101];
int main()
{
int i,n,sum;
scanf("%d",&n);
sum=0;
i=0;
while(1){
i++;
sum=i*(i+1)*(i+2)/6;
if(sum>n){
break;
}
}
printf("%d\n",i-1);
return 0;
}
解题说明:水题一道,熟悉通项公式求和即可。
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
int a[100101],b[101];
int main()
{
int i,n,sum;
scanf("%d",&n);
sum=0;
i=0;
while(1){
i++;
sum=i*(i+1)*(i+2)/6;
if(sum>n){
break;
}
}
printf("%d\n",i-1);
return 0;
}
相关文章推荐
- Codeforces 492A. Vanya and Cubes 水
- codeforces——492A——Vanya and Cubes
- 492A - Vanya and Cubes
- 492A - Vanya and Cubes
- CodeForces 546 A - Soldier and Bananas(模拟求和)
- CodeForces 552C-Vanya and Scales【思维】
- 【39.29%】【codeforces 552E】Vanya and Brackets
- 【矩阵快速幂 】Codeforces 450B - Jzzhu and Sequences (公式转化)
- 【12.78%】【codeforces 677D】Vanya and Treasure
- CodeForces-552A - Vanya and Table
- Codeforces 552D. Vanya and Triangles【向量判三点共线】
- Codeforces 525E Anya and Cubes【折半枚举法+剪枝Dfs】好题~
- 【25.33%】【codeforces 552D】Vanya and Triangles
- 【19.05%】【codeforces 680D】Bear and Tower of Cubes
- codeforces 680D D. Bear and Tower of Cubes(dfs+贪心)
- [CodeForces 677D] Vanya and Treasure (二维树状数组+静态前缀最小值)
- Codeforces 552E - Vanya and Brackets (中缀表达式求值)
- CodeForces-552B - Vanya and Books
- CodeForces 552B-Vanya and Books
- 【30.23%】【codeforces 552C】Vanya and Scales