[HDU] [1001] Sum Problem

Problem Description

Loading...

Problem Analysis

Sum of the first n terms — nothing much to say about it
but HDU 1001 always calls for a remark or two

cpp
1
2
3
4
5
6
7
8
#include<stdio.h>
int main()
{
    double n;
    while(scanf("%lf",&n)!=EOF)
        printf("%d\n\n",(int)(n*(n+1)/2));
    return 0;
}

Loading...