
http://acm.hdu.edu.cn/showproblem.php?pid=2007
没有规定 x一定小于 y
#include<cstdio>
#include<string>
#include<cstring>
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int main(void)
{
int a,b;
while(cin>>a>>b)
{
if(a>b) swap(a,b);
long long int ans1=0,ans2=0;
for(int i=a;i<=b;i++)
{
if(i&1) ans2+=pow(i,3);
else ans1+=pow(i,2);
}
cout<<ans1<<" "<<ans2<<endl;
}
return 0;
}
本文提供了一个解决HDU 2007问题的C++代码示例,该问题是计算两个整数范围内奇数立方和与偶数平方和。通过使用条件判断和循环结构实现了对指定范围内的数值进行遍历并计算各自对应的和。

1738

被折叠的 条评论
为什么被折叠?



