杭电acm 1001

#include<cstdio>

int main()

{

    int n;

    while(scanf("%d",&n)!=EOF)

    {

        if(n%2==0)

        printf("%d\n\n",n/2*(n+1));

        else

        printf("%d\n\n",(n+1)/2*n); 

    }

    return 0;

}

//通过

 

#include<cstdio>

int main()

{

    int n;

    while(scanf("%d",&n))

    {

        if(n%2==0)

        printf("%d\n\n",n/2*(n+1));

        else

        printf("%d\n\n",(n+1)/2*n); 

    }

    return 0;

}

//超时

区别: EOF

这道题主要考虑数据溢出!!!

你可能感兴趣的:(ACM)