HDOJ 2010

//多次测试,发现原因是reNo,reSp如果不在循环体中初始化为0,多次输入数据会错误。
//解决方法一如下。二直接把reNo,reSp的定义放在while里面

#include "stdio.h"

int main(void){
	int m, n;
	int bw, sw, gw;
	int reNo = 0;	 //判断是否输出no
	int reSp = 0;	//判断输出空格 

	while(scanf("%d%d", &m, &n) != EOF){
		while(m <= n){
			bw = m / 100;
			sw = (m - bw * 100) / 10;
			gw = m % 10;

			if(m == bw*bw*bw + sw*sw*sw + gw*gw*gw){
				if(reSp)
					printf(" ");
				printf("%d", m);			//printf("%d ", m); Compilation Error
				reNo = 1;
				reSp++;
			}

			m++;
		}

		if(reNo == 0)
			printf("no");
		printf("\n");

		reNo = 0;
		reSp = 0;
	}

	return 0;
}
时间: 2024-10-13 03:05:02

HDOJ 2010的相关文章

ZOJ问题(2010浙江大学研究生复试上机题目[找规律] hdoj 3788)

ZOJ问题 pid=3788">点击打开链接 Time Limit: 2000/1000 MS (Java/Others)????Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 3341????Accepted Submission(s): 1002 Problem Description 对给定的字符串(仅仅包括'z','o','j'三种字符),推断他能否AC. 是否AC的规则例如以下: 1. zoj能AC:

HDOJ 3376 Matrix Again

和HDOJ 2686 一样,只是范围不同 最大费用最大流..... 与最小费用最大流的区别用////////////标出来了 对于detour,在源点和汇点处的边的流量为2 对于每个点只能经过一次,拆点,两个点直接建一条流量为1,费用为mp[i][j]的边 对于每个点可以走到他的左边和下边:连一个费用为0流量大于1的边 Matrix Again Time Limit: 5000/2000 MS (Java/Others)    Memory Limit: 102400/102400 K (Jav

HDOJ 3436 Queue-jumpers

N的范围很大,但Q的范围比较小.可以把TOP,QUERY操作用到的点分离出来,没用到的段缩成点 对于TOP 把x转到根,删除后加到开头位置 对于QUERY 旋转到根直接输出 对于RANK,递归 Queue-jumpers Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2216    Accepted Submission(s): 56

HDOJ题目3309 Roll The Cube(BFS)

Roll The Cube Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 502    Accepted Submission(s): 181 Problem Description This is a simple game.The goal of the game is to roll two balls to two holes

HDOJ 3507 Print Article

斜率优化DP Print Article Time Limit: 9000/3000 MS (Java/Others)    Memory Limit: 131072/65536 K (Java/Others) Total Submission(s): 5519    Accepted Submission(s): 1707 Problem Description Zero has an old printer that doesn't work well sometimes. As it is

HDOJ 3518 Boring counting

SAM基本操作 拓扑求每个节点的  最左出现left,最右出现right,出现了几次num ...... 对于每一个出现两次以上的节点,对其所对应的一串子串的长度范围 [fa->len+1,len] 和其最大间距 right-left比较 即可...... Boring counting Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s):

HDOJ 3339 In Action

最短路+01背包 In Action Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 3857    Accepted Submission(s): 1229 Problem Description Since 1945, when the first nuclear bomb was exploded by the Manhattan

【HDOJ】【3506】Monkey Party

DP/四边形不等式 裸题环形石子合并…… 拆环为链即可 1 //HDOJ 3506 2 #include<cmath> 3 #include<vector> 4 #include<cstdio> 5 #include<cstring> 6 #include<cstdlib> 7 #include<iostream> 8 #include<algorithm> 9 #define rep(i,n) for(int i=0;i

HDOJ 题目3518 Boring counting(后缀数组,求不重叠重复次数最少为2的子串种类数)

Boring counting Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 2253    Accepted Submission(s): 924 Problem Description 035 now faced a tough problem,his english teacher gives him a string,whic