HOJ-1004

仔细看看了HOJ的网站,居然没说代码的大小限制。

果断打表啊。

打表打法好,打表保平安。

 1 #include<cstdio>
 2
 3 int ans[5951] = {} //表格过于丧心病狂
 4
 5 int main(void)
 6 {
 7   int a, b;
 8   int i;
 9   scanf("%d%d", &a, &b);
10
11   for(i = 0; i < 5951; ++i)
12     if(ans[i] >= a) break;
13   for( ; i < 5951; ++i){
14     if(ans[i] <= b) printf("%d\n", ans[i]);
15     else break;
16   }
17
18   return 0;
19 }
时间: 2024-08-01 17:49:59

HOJ-1004的相关文章

hoj 1004 Prime Palindromes(还是不够完美)

The number 151 is a prime palindrome because it is both a prime number and a palindrome (it is the same number when read forward as backward). Write a program that finds all prime palindromes in the range of two supplied numbers a and b (5 <= a < b

HOJ 1004: Prime Palindromes

问题:输入两个整数 a 和 b (5 <= a < b <= 1,000,000,000),输出 [a, b] 内的所有回文质数. 最简单的暴力解法是依次遍历 [a, b] 范围内的所有奇数.如果是回文质数,则输出. 另一种解法是按顺序构造 [5, 1,000,000,000] 内的所有回文数,如果在 [a, b] 范围内,而且是质数,则输出. 更好的解法是将 [5, 1,000,000,000] 内的所有回文质数存于数组.然后用二分查找法分别找到 a,b 所对应的下标,输出下标范围内的

HOJ 题目分类

转自:http://blog.sina.com.cn/s/blog_65f3869301011a1o.html ******************************************************************************* 简单题(包括枚举,二分查找,(复杂)模拟,基础数据结构(栈.队列),杂题等 ****************************************************************************

HDU 4864(多校)1004 Task

Problem Description Today the company has m tasks to complete. The ith task need xi minutes to complete. Meanwhile, this task has a difficulty level yi. The machine whose level below this task's level yi cannot complete this task. If the company comp

HDU 1004 Let the Balloon Rise【STL&lt;map&gt;】

Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 123800    Accepted Submission(s): 48826 Problem Description Contest time again! How excited it is to see balloons floating ar

51Nod - 1004 n^n的末位数字

51Nod - 1004 n^n的末位数字 给出一个整数N,输出N^N(N的N次方)的十进制表示的末位数字. Input 一个数N(1 <= N <= 10^9) Output 输出N^N的末位数字 Input示例 13 Output示例 3 题解: 末尾数字,所以在快速迭代幂的时候,只需要考虑末尾数字即可. #include <iostream> #include <cstdio> #include <cstdlib> #include <cstri

Codevs 1004 四子连棋

1004 四子连棋 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 黄金 Gold 题目描述 Description 在一个4*4的棋盘上摆放了14颗棋子,其中有7颗白色棋子,7颗黑色棋子,有两个空白地带,任何一颗黑白棋子都可以向上下左右四个方向移动到相邻的空格,这叫行棋一步,黑白双方交替走棋,任意一方可以先走,如果某个时刻使得任意一种颜色的棋子形成四个一线(包括斜线),这样的状态为目标棋局. ● ○ ●   ○ ● ○ ● ● ○ ● ○ ○ ● ○   输入描述 Input

HOJ 1797 Red and Black

传送门  http://acm.hit.edu.cn/hoj/problem/view?id=1797 总体的思路是遍历可以到达的' . ',将其对应的vis数组化为1,然后统计所有为1的vis项; ①常用的加边法,防止越界 ②初始化,不然两次相同的输入得到的结果会不同,由于是二维数组,能力有限,只好在结尾初始化,为下次输入做准备 ③结束条件,递归函数一定要先写好结束条件,不然会炸 ④上下左右四向移动 ⑤直接递归函数调用自身 1 #include <stdio.h> 2 #include &l

1004 四子连棋

1004 四子连棋 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 黄金 Gold 题解 题目描述 Description 在一个4*4的棋盘上摆放了14颗棋子,其中有7颗白色棋子,7颗黑色棋子,有两个空白地带,任何一颗黑白棋子都可以向上下左右四个方向移动到相邻的空格,这叫行棋一步,黑白双方交替走棋,任意一方可以先走,如果某个时刻使得任意一种颜色的棋子形成四个一线(包括斜线),这样的状态为目标棋局. ● ○ ●   ○ ● ○ ● ● ○ ● ○ ○ ● ○   输入描述 In

BestCoder Round #62 (div.2) 1004

好长时间没做比赛了,原来就菜现在更菜,1004的题目没想到div.2赛后只有一个人做出来,做题的时候想到了做法但时间不多自己的奇葩代码不足以在比赛时间debug出来,赛后补了一发: 题目&提交地址在这:http://acm.hdu.edu.cn/showproblem.php?pid=5565 const int INF = 1000000000; const double eps = 1e-8; const int maxn = 10000000 + 10; const int mod = 1