HDU 2007

/*杭电ACM ID:2007*/
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main()
{
	int in1, in2, out1, out2;
	int temp = 0, min, max;
	while (scanf("%d %d", &in1, &in2) != EOF){
		if (in1 < in2){
			min = in1;
			max = in2;
		}
		else{
			min = in2;
			max = in1;
		}
		temp = min;
		out1 = 0;
		out2 = 0;
		for (; temp <= max; temp++){
			if (temp % 2 == 0){
				out1 += temp*temp;
			}
			else{
				out2 += temp*temp*temp;
			}
		}
		printf("%d %d\n", out1, out2);
	}
}

  是否正确有待验证

时间: 2025-01-09 03:23:34

HDU 2007的相关文章

hdu 2007 注意m n大小

http://acm.hdu.edu.cn/showproblem.php?pid=2007 #include<iostream> #include<stdio.h> #include<math.h> #include<queue> #include<stack> #include<algorithm> #define PI 3.1415927 using namespace std; int main() { int m,n,i;

HDU 2007 平方和与立方和

http://acm.hdu.edu.cn/showproblem.php?pid=2007 Problem Description 给定一段连续的整数,求出他们中所有偶数的平方和以及所有奇数的立方和. Input 输入数据包含多组测试实例,每组测试实例包含一行,由两个整数m和n组成. Output 对于每组输入数据,输出一行,应包括两个整数x和y,分别表示该段连续的整数中所有偶数的平方和以及所有奇数的立方和.你可以认为32位整数足以保存结果. Sample Input 1 3 2 5 Samp

HDU 2007 (水)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2007 题目大意:给你段连续数字,让你求 all sum of (偶数2 )and all sum of (奇数3 ) 解题思路: 暴力遍历这段数字,判断奇偶数,搞一下就行,但对于弱菜的我来说还是学到挺多的. 先上代码吧 代码: 1 #include<iostream> 2 #include<cmath> 3 #include<cstdio> 4 #include<io

HDU 1853 Cyclic Tour(最小费用最大流)

Cyclic Tour Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/65535 K (Java/Others) Total Submission(s): 1879    Accepted Submission(s): 938 Problem Description There are N cities in our country, and M one-way roads connecting them. Now L

hdu 1851(A Simple Game)(sg博弈)

A Simple Game Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/65535 K (Java/Others)Total Submission(s): 1487    Accepted Submission(s): 939 Problem Description Agrael likes play a simple game with his friend Animal during the classes. I

Cyclic Tour (hdu 1853 二分图最小权问题)

Cyclic Tour Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/65535 K (Java/Others) Total Submission(s): 1883    Accepted Submission(s): 941 Problem Description There are N cities in our country, and M one-way roads connecting them. Now L

(KM) hdu 1853

Cyclic Tour Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/65535 K (Java/Others)Total Submission(s): 1812    Accepted Submission(s): 910 Problem Description There are N cities in our country, and M one-way roads connecting them. Now Li

hdoj-1856-More is better【并查集】

More is better Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 327680/102400 K (Java/Others) Total Submission(s): 18427 Accepted Submission(s): 6779 Problem Description Mr Wang wants some boys to help him with a project. Because the project is r

hdu2005~2009

hdu 2005 给定一个日期,输出这个日期是该年的第几天. 水……可能主要是分类讨论烦一点吧 1 #include<stdio.h> 2 int main() 3 { 4 int year,month,day,d=0,i; 5 int m[12]={31,28,31,30,31,30,31,31,30,31,30,31}; 6 while (scanf("%d/%d/%d",&year,&month,&day)!=EOF) 7 { 8 for (i