POJ Find The Multiple 1426 (搜索)】的更多相关文章

Find The Multiple Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 22576   Accepted: 9291   Special Judge Description Given a positive integer n, write a program to find out a nonzero multiple m of n whose decimal representation contains…
转载自:優YoU  http://user.qzone.qq.com/289065406/blog/1303946967 以下内容属于以上这位dalao http://poj.org/problem?id=1426 题意 给出一个整数n,(1 <= n <= 200).求出任意一个它的倍数m,要求m必须只由十进制的'0'或'1'组成. 分析 首先暴力枚举肯定是不可能的 1000ms 想不超时都难,而且枚举还要解决大数问题.. 要不是人家把这题放到搜索,怎么也想不到用BFS... 解题方法: B…
http://poj.org/problem?id=3126 搜索的时候注意 1:首位不能有0 2:可以暂时有没有出现在目标数中的数字 #include <cstdio> #include <cstring> #include <queue> using namespace std; const int maxn=1e4+5; const int inf=0x7fffffff; bool prim[maxn]; void judge(){ prim[2]=true; f…
题目链接 http://poj.org/problem?id=1426 题意 输入一个数n,输出任意一个 只含0.1且能被n整除的数m.保证n<=200,m最多100位. 题解 DFS/BFS都能做. 这里使用DFS.然后T了.就变成了打表A了.emm ,m最多会19位,这点我也很迷==. 其他 使用了Java大数,get了打开方式. todo 为啥m19?? BFS法 0/1背包法 和鸽笼原理有什么关系? 代码 打表A版 import java.math.BigInteger; import…
Find The Multiple Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 18012   Accepted: 7297   Special Judge Description Given a positive integer n, write a program to find out a nonzero multiple m of n whose decimal representation contains…
Find The Multiple Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 42035   Accepted: 17654   Special Judge Description Given a positive integer n, write a program to find out a nonzero multiple m of n whose decimal representation contains…
题目链接:http://poj.org/problem?id=1088 题意很好懂,就是让你求一个最长下降路线的长度. dp[i][j]记录的是i j这个位置的最优的长度,然后转移方程是dp[i][j] = max(dp[i][j - 1], dp[i - 1][j], dp[i][j + 1], dp[i + 1][j]) + 1. 已知最低点的答案 慢慢倒推到高点的答案.(还是对记忆化搜不熟练啊) #include <iostream> #include <cstdio> #i…
简单搜索 练习一下回溯 #include <iostream> #include <cstdio> #include <cstring> #include <sstream> #include <string> #include <algorithm> #include <list> #include <map> #include <vector> #include <queue> #i…
Description 在一个给定形状的棋盘(形状可能是不规则的)上面摆放棋子,棋子没有区别.要求摆放时任意的两个棋子不能放在棋盘中的同一行或者同一列,请编程求解对于给定形状和大小的棋盘,摆放k个棋子的所有可行的摆放方案C. Input 输入含有多组测试数据. 每组数据的第一行是两个正整数,n k,用一个空格隔开,表示了将在一个n*n的矩阵内描述棋盘,以及摆放棋子的数目. n <= 8 , k <= n 当为-1 -1时表示输入结束. 随后的n行描述了棋盘的形状:每行有n个字符,其中 # 表示…
POJ 1390 Blocks 砌块 时限:5000 MS   内存限制:65536K 提交材料共计: 6204   接受: 2563 描述 你们中的一些人可能玩过一个叫做“积木”的游戏.一行有n个块,每个盒子都有一个颜色.这是一个例子:金,银,铜,金.相应的图片如下: 图1如果一些相邻的盒子都是相同的颜色,并且它左边的盒子(如果它存在)和它的右边的盒子(如果它存在)都是其他颜色的,我们称它为“盒子段”.有四个盒子段.那就是:金,银,铜,金.片段中分别有1,4,3,1方框. 每次您可以单击一个框…
POJ 1088 滑雪 Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 107319   Accepted: 40893 Description Michael喜欢滑雪百这并不奇怪, 因为滑雪的确很刺激.可是为了获得速度,滑的区域必须向下倾斜,而且当你滑到坡底,你不得不再次走上坡或者等待升降机来载你.Michael想知道载一个区域中最长底滑坡.区域由一个二维数组给出.数组的每个数字代表点的高度.下面是一个例子 1 2 3…
Description Every year the cows hold an event featuring a peculiar version of hopscotch that involves carefully jumping from rock to rock in a river. The excitement takes place on a long, straight river with a rock at the start and another rock at th…
Description 在一个给定形状的棋盘(形状可能是不规则的)上面摆放棋子,棋子没有区别.要求摆放时任意的两个棋子不能放在棋盘中的同一行或者同一列,请编程求解对于给定形状和大小的棋盘,摆放k个棋子的所有可行的摆放方案C. Input 输入含有多组测试数据. 每组数据的第一行是两个正整数,n k,用一个空格隔开,表示了将在一个n*n的矩阵内描述棋盘,以及摆放棋子的数目. n <= 8 , k <= n 当为-1 -1时表示输入结束. 随后的n行描述了棋盘的形状:每行有n个字符,其中 # 表示…
Find a multiple The input contains N natural (i.e. positive integer) numbers ( N <= 10000 ). Each of that numbers is not greater than 15000. This numbers are not necessarily different (so it may happen that two or more of them will be equal). Your ta…
Shredding Company Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 6173   Accepted: 3361 Description You have just been put in charge of developing a new shredder for the Shredding Company Although a "normal" shredder would just shre…
题意: 给出一个数T,再给出n个数.若n个数中有几个数(可以是一个)的和是T,就输出相加的式子.不过不能输出相同的式子. 分析: 运用的是回溯法.比较特殊的一点就是不能输出相同的式子.这个可以通过map来实现:map<string,int>把字符串(可以是C语言的字符串)和整数联系起来了.我们可以把相加起来的几个数变成一个字符串(2+1+1,变成“211”),如果它出现过,就标记为1,初始值是0.出现过的就不再输出了. 剪枝: 1.所有的数加起来的和小于T,直接输出NONE. 2.搜索过程中,…
Problem Description 定义一个二维数组: int maze[5][5] = { 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, }; 它表示一个迷宫,其中的1表示墙壁,0表示可以走的路,只能横着走或竖着走,不能斜着走,要求编程序找出从左上角到右下角的最短路线. Input 一个5 × 5的二维数组,表示一个迷宫.数据保证有唯一解. Output 左上角到右下角的最短路径,格式如…
Hopscotch Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 6761   Accepted: 4354 Description The cows play the child's game of hopscotch in a non-traditional way. Instead of a linear set of numbered boxes into which to hop, the cows creat…
话说DP=记忆化搜索这句话真不是虚的. 面对这道题目,题意很简单,但是DP的时候,方向分为四个,这个时候用递推就好难写了,你很难得到当前状态的前一个真实状态,这个时候记忆化搜索就派上用场啦! 通过对四个方向进行搜索,即可得到当前状态的最优解. #include <iostream> #include <cstdio> using namespace std; ][]; ][]; ]= {{,},{,-},{,},{-,}}; int r,c; int dpac(int i,int…
You are trapped in a 3D dungeon and need to find the quickest way out! The dungeon is composed of unit cubes which may or may not be filled with rock. It takes one minute to move one unit north, south, east, west, up or down. You cannot move diagonal…
You are trapped in a 3D dungeon and need to find the quickest way out! The dungeon is composed of unit cubes which may or may not be filled with rock. It takes one minute to move one unit north, south, east, west, up or down. You cannot move diagonal…
题意:就是找最短的四位数素数路径 分析:然后BFS随便搜一下,复杂度最多是所有的四位素数的个数 #include<cstdio> #include<algorithm> #include<iostream> #include<cstring> #include<cmath> #include<map> #include<queue> #include<stdlib.h> #include<string&g…
Prime Path Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 20237   Accepted: 11282 Description The ministers of the cabinet were quite upset by the message from the Chief of Security stating that they would all have to change the four-di…
点这里去看题 思路:本题的难点在k<n的情况,所以我们可以另dfs中的两个参数分别代表起始行和待放棋子个数(待放棋子只能放在起始行后面的行),然后用一个c[8]来表示每一列放旗子的情况来判断列不重复 #include<stdio.h> #include<algorithm> #include<string.h> using namespace std; ][],c[],n,k,ans; void dfs(int x,int num) { int j,tx,nu;…
Lake Counting Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 48370 Accepted: 23775 Description Due to recent rains, water has pooled in various places in Farmer John's field, which is represented by a rectangle of N x M (1 <= N <= 100; 1…
[题目链接]click here~~ [题目大意]: 农夫约翰知道聪明的牛产奶多. 于是为了提高牛的智商他准备了例如以下游戏. 有一个M×N 的格子,每一个格子能够翻转正反面,它们一面是黑色,还有一面是白色.黑色的格子翻转后就是白色.白色的格子翻转过来则是黑色. 游戏要做的就是把全部的格子都翻转成白色. 只是由于牛蹄非常大,所以每次翻转一个格子时.与它上下左右相邻接的格子也会被翻转.由于翻格子太麻烦了.所以牛都想通过尽可能少的次数把全部格子都翻成白色.如今给定了每一个格子的颜色.请求出用最小步数…
参考:https://www.cnblogs.com/ACShiryu/archive/2011/08/09/poj2356.html 鸽巢原理??? 其实不用map但是习惯了就打的map 以下C-c自参考博客: 我们可以依次求出a[0],a[0]+a[1],a[0]+a[1]+a[2],......,a[0]+a[1]+a[2]...+a[n]: 假设分别是sum[0],sum[1],sum[2],......,sum[n] 如果在某一项存在是N的倍数,则很好解,即可直接从第一项开始直接输出答…
Blocks Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 4318   Accepted: 1745 Description Some of you may have played a game called 'Blocks'. There are n blocks in a row, each box has a color. Here is an example: Gold, Silver, Silver, Sil…
Hopscotch Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 2774 Accepted: 1940 Description The cows play the child's game of hopscotch in a non-traditional way. Instead of a linear set of numbered boxes into which to hop, the cows create a…
Smallest Difference Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 6493   Accepted: 1771 Description Given a number of distinct decimal digits, you can form one integer by choosing a non-empty subset of these digits and writing them in…