Topic Portal
1 /*2 Test instructions: Find out a number consisting of 0 and 1 to divide n3 the range of dfs:200 will not explode long long,dfs water too ~4 */5 /************************************************6 Author:running_time7 Created time:2015-8-2 14:21:518 File Name:P oj_1426.cpp9 *************************************************/Ten One#include <cstdio> A#include <algorithm> -#include <iostream> -#include <sstream> the#include <cstring> -#include <cmath> -#include <string> -#include <vector> +#include <queue> -#include <deque> +#include <stack> A#include <list> at#include <map> -#include <Set> -#include <bitset> -#include <cstdlib> -#include <ctime> - using namespacestd; in -typedefLong Longll; to Const intMAXN = 1e4 +Ten; + Const intINF =0x3f3f3f3f; - Const intMOD = 1e9 +7; the ll N; * BOOLOK; $ Panax Notoginseng voidDFS (ll X,intStepintDEP) { - if(OK)return ; the if(Step >= DEP)return ; + if(x% n = =0) { Aprintf ("%i64d\n", x); theOK =true;return ; + } -DFS (x *Ten, Step +1, DEP); $DFS (x *Ten+1, Step +1, DEP); $ } - - intMainvoid) {//POJ 1426 Find the multiple the while(SCANF ("%i64d", &n) = =1) { - if(!n) Break;WuyiOK =false; ll dep =1; the while(true) { - if(OK) Break; WuDFS (1,0, DEP); dep++; - } About } $ - return 0; -}
1 /*2 bfs+ comodule theorem: MoD array preservation, the remainder of each bit, the current number is recursive by a number less digit,3 For example, 4 (100) can be introduced from 2 (10), online code too hanging, worship the4 Detailed Explanation:http://blog.csdn.net/lyy289065406/article/details/66479175 */6 /************************************************7 Author:running_time8 Created time:2015-8-2 15:14:339 File Name:P oj_1426_bfs.cppTen *************************************************/ One A#include <cstdio> -#include <algorithm> -#include <iostream> the#include <sstream> -#include <cstring> -#include <cmath> -#include <string> +#include <vector> -#include <queue> +#include <deque> A#include <stack> at#include <list> -#include <map> -#include <Set> -#include <bitset> -#include <cstdlib> -#include <ctime> in using namespacestd; - to #defineLson L, Mid, RT << 1 + #defineRson mid + 1, R, RT << 1 | 1 -typedefLong Longll; the Const intMAXN = 1e6 +Ten; * Const intINF =0x3f3f3f3f; $ Const intMOD = 1e9 +7;Panax Notoginseng intMOD[MAXN]; - intANS[MAXN]; the + intMainvoid) { A intN; the while(SCANF ("%d", &n) = =1) { + if(!n) Break; -mod[1] =1;inti; $ for(i=2; mod[i-1]; ++i) { $Mod[i] = (mod[i/2] *Ten+ (i&1))% n;//two-inlet simulation of BFS - } - intt =0; i--; the while(i) { -Ans[++t] = i &1;WuyiI/=2; the } - while(t) { Wuprintf ("%d", ans[t--]); - } AboutPuts (""); $ } - - return 0; -}
BFS
Dfs/bfs (with Comodule) POJ 1426 Find the multiple