2015年11月03日
来源:互联网 发布:淘宝连帽 编辑:程序博客网 时间:2024/05/20 18:40
今天写2007,比2006稍微难了一点点。这个也就是输入m,n,然后这区间的数判断,是偶数就平方然加到平方和,否则就立方再加到立方和。
比较简单的题,就不弄代码了。
对了 ,题中没有说m小于n的,需要自己判断哦。
import java.util.Scanner;
class Main{
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
while(sc.hasNext()){
int m = sc.nextInt();
int n = sc.nextInt();
if(m>n){
m=m+n;
n=m-n;
m=m-n;
}
int x=0,y=0;
for(int i=m;i<=n;i++){
if(i%2==0){
x+=i*i;
}
else{
y+=i*i*i;
}
}
System.out.print(x+" ");
System.out.println(y);
}
}
}
0 0
- 2015年11月03日
- 未亡羊先补牢-2015年03月18日
- 2015年03月29日
- 日记 [2008年03月11日]
- 2010年11月03日
- 2010年11月03日
- 2015年2月11日
- 2015年3月11日工作总结
- 2015年3月11日
- 2015年7月11日UITableView3
- 2015年7月11日-FW
- 2015年9月11日
- 2015年11月5日小记
- 2015年11月6日
- 2015年11月8日 开篇
- 2015年11月9日杂谈
- 2015年11月12日
- 2015年11月13日
- 2015年10月29日
- 错误信息,clean失败 Error:Execution failed for task ':clean'. > Unable to delete directory :\build\intermed
- 2015年10月30日
- 2015年11月01日
- laravel 框架自带表单验证
- 2015年11月03日
- 数据库的事务隔离级别
- 2015年11月04日
- 2015年11月05日
- 2015年11月15日
- 2015年11月30日
- 2020 绝对值排序
- 哈希检索方面的论文、代码和数据集Learning to Hash Paper, Code and Dataset
- 杭电2021 发工资咯:)