0
点赞
收藏
分享

微信扫一扫

SPOJ 1167(Move To Invert-三角形硬币阵颠倒)


SPOJ Problem Set (classical)

1167. Move To Invert

Problem code: MINCOUNT

 

SPOJ 1167(Move To Invert-三角形硬币阵颠倒)_打表


For h=4 at least 3 coins must be moved to invert it.

Input

In the first line N will be given and then N lines follow with each line having a integer which is the height of triangle in that test case.00≤h<1010;

Output

For each test case output in a seperate line the minimum number of moves required to invert the triangle. Output fits in long long data type

Example


Inputt: 1 3 Output: 2



答案是n(n+1) div 6


这是纯粹的打表找规律题……


注意Comments中对%lli的注解(等待C++有识之士解释……)


#include<cstdio>
#include<cstring>
using namespace std;
unsigned long long n;
int main()
{
scanf("%lli",&n);
while (scanf("%lli",&n)!=EOF) printf("%lli\n",n*(n+1)/6);
return 0;
}




举报

相关推荐

空心三角形

递归三角形

三角形面积

三角形判断

【数字三角形】

星号三角形

绘制三角形

0 条评论