poj1426 Find The Multiple (DFS)】的更多相关文章

题目: Find The Multiple Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 41845   Accepted: 17564   Special Judge Description Given a positive integer n, write a program to find out a nonzero multiple m of n whose decimal representation cont…
POJ1426--Find The Multiple Description Given a positive integer n, write a program to find out a nonzero multiple m of n whose decimal representation contains only the digits 0 and 1. You may assume that n is not greater than 200 and there is a corre…
Find The Multiple Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 36335   Accepted: 15194   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 a multiple Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 7133 Accepted: 3122 Special Judge Description The input contains N natural (i.e. positive integer) numbers ( N <= 10000 ). Each of that numbers is not greater than 15000. This…
Find The Multiple Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 24768   Accepted: 10201   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: 14622   Accepted: 5938   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=1426 Description Given a positive integer n, write a program to find out a nonzero multiple m of n whose decimal representation contains only the digits 0 and 1. You may assume that n is not greater than 200 and there is a c…
题目链接:http://poj.org/problem?id=1426 Find The Multiple Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 34218   Accepted: 14337   Special Judge Description Given a positive integer n, write a program to find out a nonzero multiple m of n w…
题目链接 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…
题意: 给一个数n,让你找出一个只有1,0,组成的十进制数,要求是找到的数可以被n整除. 用DFS是搜索 当前位数字 (除最高位固定为1),因为每一位都只有0或1两种选择,换而言之是一个双入口BFS. 用DFS也可用queue代替BFS也可. #include<iostream> #include<cstdlib> #include<cstdio> #include<cstring> #include<queue> #include<alg…
参考:http://www.cnblogs.com/ACShiryu/archive/2011/07/24/2115356.html #include <iostream> #include <cstdio> #include <cstring> #include <queue> using namespace std; int main() { int n; while (cin>>n,n) { queue<long long> q…
传送门 转:http://blog.csdn.net/wangjian8006/article/details/7460523 (比较好的记录路径方案) #include<iostream> #include<cstring> #include<cstdlib> #include<cstdio> #include<algorithm> #include<cmath> #include<queue> #include<…
POJ 1426 Find The Multiple 题意:给定一个整数n,求n的一个倍数,要求这个倍数只含0和1 参考博客:点我 解法一:普通的BFS(用G++能过但C++会超时) 从小到大搜索直至找到满足条件的数,注意最高位一定为1 假设 n=6  k即为当前所求的目标数,不满足条件则进一步递推 (i 为层数(深度),在解法二的优化中体现,此时可以不管) 1%6=1 (k=1) i=1 { (1*10+0)%6=4 (k=10) i=2 { (10*10+0)%6=4 (k=100) i=4…
图论 图论解题报告索引 DFS poj1321 - 棋盘问题 poj1416 - Shredding Company poj2676 - Sudoku poj2488 - A Knight's Journey poj1724 - ROADS(邻接表+DFS) BFS poj3278 - Catch That Cow(空间BFS) poj2251 - Dungeon Master(空间BFS) poj3414 - Pots poj1915 - Knight Moves poj3126 - Prim…
-->Find The Multiple 原文是英语,直接上中文了 Descriptions: 给定一个正整数n,请编写一个程序来寻找n的一个非零的倍数m,这个m应当在十进制表示时每一位上只包含0或者1.你可以假定n不大于200且m不多于100位. 提示:本题采用Special Judge,你无需输出所有符合条件的m,你只需要输出任一符合条件的m即可. Input 输入包含多组数据,每组数据仅一行,只包含一个正整数n (1 <= n <= 200). Output 对于输入的每组n,都输…
Find The Multiple Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 16505   Accepted: 6732   Special Judge Description Given a positive integer n, write a program to find out a nonzero multiple m of n whose decimal representation contains…
题目: Given a positive integer n, write a program to find out a nonzero multiple m of n whose decimal representation contains only the digits 0 and 1. You may assume that n is not greater than 200 and there is a corresponding m containing no more than…
Given a positive integer n, write a program to find out a nonzero multiple m of n whose decimal representation contains only the digits 0 and 1. You may assume that n is not greater than 200 and there is a corresponding m containing no more than 100…
题目传送门 /* 题意:找出一个0和1组成的数字能整除n DFS:200的范围内不会爆long long,DFS水过~ */ /************************************************ Author :Running_Time Created Time :2015-8-2 14:21:51 File Name :POJ_1426.cpp *************************************************/ #include…
Description Given a positive integer n, write a program to find out a nonzero multiple m of n whose decimal representation contains only the digits 0 and 1. You may assume that n is not greater than 200 and there is a corresponding m containing no mo…
题目链接:id=1426">Find The Multiple 解析:直接从前往后搜.设当前数为k用long long保存,则下一个数不是k*10就是k*10+1 AC代码: /* DFS */ #include <cstdio> #include <iostream> #include <algorithm> #include <queue> using namespace std; long long n; int DEEP; bool…
本题传送门 本题知识点:深度优先搜索 | 宽度优先搜索 题意很简单,让我们找一个只有1和0组成的十位数是n的倍数的数. 这题一开始吓到我了--因为Output里说输出的长度最长不超过100位???那是不是要用字符串了?不过貌似在[1, 200]里,他们的倍数好像都在18位内,即用unsigned long long就可以解决.(BUG?) 若想学习输出100位的可以看看这篇博客 数据很小. // POJ 1426 #include<iostream> #include<cstdio>…
题目链接:https://vjudge.net/problem/POJ-1426 题意:给出n(1<=n<=200),求出全部由01组成的能整除n的正整数. 思路:此题在unsigned long long以内就可以找到满足条件的数,因此限制递归深度为20,然后枚举每一位两种可能即可. AC代码: #include<cstdio> #include<algorithm> using namespace std; ]; void dfs(int pos,int pre){…
Description Given a positive integer n, write a program to find out a nonzero multiple m of n whose decimal representation contains only the digits 0 and 1. You may assume that n is not greater than 200 and there is a corresponding m containing no mo…
题目链接 http://poj.org/problem?id=1426 题意 给出一个数 要求找出 只有 0 和 1 组成的 十进制数字 能够整除 n n 不超过 200 十进制数字位数 不超过100 思路 其实 十进制数字位数 不超过 20 下就有可以满足的答案 所以直接用 unsinged long long 就可以过了 .. AC代码 #include <cstdio> #include <cstring> #include <ctype.h> #include…
题目链接:Find the Multiple 题目大意 找出一个只由0和1组成的能整除n的数. 思路 所有由0和1组成的数可以看作是某个只由0.1组成的数a经过以下两种变化得到 1.a * 10 2.a * 10+1 因此只需要用BFS搜索满足条件的数即可. 题解 #include <iostream> #include <cstring> #include <queue> using namespace std; long long n; int main(int a…
题意:输入一个不超过200的数 n,然后求得一个数字k,数字满足:能被n整除,每一位只有0,1.这样的数字k会有很多个,然以输出一个就可以. 注意unsigned __int64的范围,-(10^19)~(10^20)所以步数不能超过19次. (摘) 附:同余模定理: (a*b)%n = (a%n *b%n)%n: (a+b)%n = (a%n +b%n)%n: #include<iostream> #include<cstdio> #include<algorithm>…
Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 3192    Accepted Submission(s): 371 Problem Description You are given a rooted tree of N nodes, labeled from 1 to N. To the ith node a non-negat…
Tempter of the Bone Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 110290    Accepted Submission(s): 29967 Problem Description The doggie found a bone in an ancient maze, which fascinated him a…
Find The Multiple Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 28550   Accepted: 11828   Special Judge Description Given a positive integer n, write a program to find out a nonzero multiple m of n whose decimal representation contains…