📄 toj_2920.cpp
字号:
/*2920. Help Hakim Time Limit: 3.0 Seconds Memory Limit: 65536KTotal Runs: 13 Accepted Runs: 4Case Time Limit: 1.0 Seconds06 batch of CUET (Chittagong University of Extra Talent) has solved the previous problem of fruit seller Hakim. He only knows to stack fruits in a single layer. He is grateful to the programmer of 06 batch.Fig: Level 3 StackNow he is in another trouble. He wants to stack fruits in 3D fashion. That means each fruit contain three fruits support under it. At the top level only exist one fruit and at the 2nd level from top there should be three fruits and the next levels from the top to bottom follow the same rule. He wants calculate the number of fruits require for N level stack. Who can help him!!!!!InputEach line of input set will contain a single integer N where 0≤N≤106.OutputOutput will contain the total number of fruits required for N level.Sample Input123Sample Output1410Problem Setter: MD. Nazmul KibriaProblem Idea: MD. Omar FaruqueSource: CUET individual contest*/#include<cstdio>int main(){ long long n , temp , result; while ( scanf( "%lld" , &n ) != EOF ) { temp = n * ( n + 1 ) / 2; result = (temp * ( 2 * n + 1 ) / 3 + temp ) / 2; printf( "%lld\n", result ); } return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -