POJ1426-Find The Multiple(DFS)
給出一個整數n,(1 <= n <= 200)。求出任意一個它的倍數m,要求m必須只由十進制的‘0‘或‘1‘組成。
#include <iostream> using namespace std; int N,flag; void DFS(int m,long long n) { if(m==19) return; if(flag) return; if(n%N==0) { flag=1; cout<<n<<endl; return; } DFS(m+1,n*10); DFS(m+1,n*10+1); } int main() { ios::sync_with_stdio(false); while(cin>>N&&N!=0) { flag=0; DFS(0,1); } return 0; }
POJ1426-Find The Multiple(DFS)
相關推薦
POJ1426-Find The Multiple(DFS)
進制 整數 amp names return CI fin != n! 給出一個整數n,(1 <= n <= 200)。求出任意一個它的倍數m,要求m必須只由十進制的‘0‘或‘1‘組成。 #include <iostream> using nam
POJ 1426 Find The Multiple(DFS,BFS)
ons pro sum 數字 there lin queue hat 一個數 Given a positive integer n, write a program to find out a nonzero multiple m of n whose decimal
POJ-1462-Find The Multiple (dfs搜尋)
原題連結: http://poj.org/problem?id=1426 Given a positive integer n, write a program to find out a nonzero multiple m of n whose decimal representat
poj1426 Find The Multiple (DFS)
targe rep org define decimal positive ostream accept cin 題目: Find The Multiple Time Limit: 1000MS Memory Limit: 10000K
poj 1426 Find The Multiple (簡單搜尋dfs)
題目: 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.
POJ 1426 Find The Multiple(數論——中國同余定理)
定義 十進制 pro desc decimal tput one return solution 題目鏈接: http://poj.org/problem?id=1426 Description Given a positive integer n, write a pro
POJ1426 Find The Multiple(BFS)
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
Find The Multiple(POJ-1426)
Problem Description Given a positive integer n, write a program to find out a nonzero multiple m of n whose decimal representation contains only t
poj 1426 Find The Multiple(打表找範圍+搜尋)
1426-Find The Multiple 題目連結http://poj.org/problem?id=1426 Time Limit: 1000MS Memory Limit: 10000K
POJ1426 Find The Multiple【BFS】
Find The Multiple Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 42543 Accepted: 17897 Special Judge
POJ 1426 Find The Multiple(bfs)
Description Given a positive integer n, write a program to find out a nonzero multiple m of n whose decimal representation contains onl
Find The Multiple(poj 1426)
Find The Multiple Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 33035 Accepted: 13823 Special Judge Description Giv
POJ 1426 Find The Multiple(kuangbin帶你飛 專題一:簡單搜尋)
題意:給定一個n,找一個能被n整除並且每一位都是0或者1的數字... 簡單bfs,第一位肯定是1,然後求得餘數,後面添一個0或者1的時候將當前餘數*10+0或者1....找到倍數後將字串後面補個‘\0’puts輸出就好了... #include<cstring>
POJ 1426 Find The Multiple(大數取模)【DFS】||【BFS】
++ printf true pty ace bfs 還要 ems 兩種 <題目鏈接> 題目大意: 給一個小於200的正整數n,問只有0和1組成的位數小於100的最小能被n整除的數是多少。 解題分析: 用DFS或者BFS沿著位數進行搜索,每一次搜索到下一位都有兩
E - Find The Multiple(DFS)(18.9.13)
E - Find The Multiple Time Limit:1000MS Memory Limit:10000KB 64bit IO Format:%I64d & %I64u Description Given a positive i
Find The Multiple POJ - 1426 (BFS)
題目大意 給定一個整數,尋找一個只有0,1構成的十進位制數使得這個數能夠整除這個整數 解法 直接bfs第一位放入1,之後每一位放入1或者0 程式碼 #include <iostream> #include <queue> using namespace std; int n;
POJ 1426 Find The Multiple 深搜廣搜(信題目你就完了系列)
Find The Multiple Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 43209 Accepted: 18144 Special Judge
poj 1426 Find The Multiple
lines code span cti its case sig pac unsigned id=1426">poj 1426 的傳送門 Language: Find The Multiple Time Limit: 1000MS Mem
Gym 101246D Fire in the Country(dfs求SG函數)
tor 我們 style sizeof std clas mem class == http://codeforces.com/gym/101246/problem/D 題意: 給定一個無向有環圖,大火從1點開始,每個時間點與它相鄰的點也將會著火,現在有兩個人輪流操作機
Kick the ball!(dfs)湖南省賽第十屆
board have class weight you determine wikipedia spa scanf Problem K: Kick the ball! Time Limit: 1 Sec Memory Limit: 128 MB S