hdu 1000 1001

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/gin_love/article/details/49970279

1000 A + B Problem

http://acm.hdu.edu.cn/showproblem.php?pid=1000

#include<iostream>
using namespace std;
int main()
{
    int a,b;
    while(cin>>a>>b)
    {
        cout<<a+b<<endl;
    }
    return 0;
}

1001 Sum Problem

http://acm.hdu.edu.cn/showproblem.php?pid=1001

#include<iostream>
using namespace std;
int main()
{
    int i,a,sum=0;
    while(cin>>a)
    {
        if(a%2==0)
            sum=a/2*(a+1);
        else
            sum=(a+1)/2*a;
        cout<<sum<<endl<<endl;
    }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/gin_love/article/details/49970279