【DFS】poj 1426 Find The Multiple
2014-05-23 17:23
393 查看
http://poj.org/problem?id=1426
分析:这个“Special Judge”真是深有含义啊,只要最近的倍数就好了嘛。
分析:这个“Special Judge”真是深有含义啊,只要最近的倍数就好了嘛。
#include <iostream> #include <queue> #include <cstdio> using namespace std; typedef __int64 LL; const int NM=205; int n,vis[NM]; LL BFS(){ queue<LL>q1; LL t=1,x1,x2; int mod1,mod2; memset(vis,0,sizeof(vis)); while(!q1.empty()) q1.pop(); vis[1%n]=1; q1.push(t); while(!q1.empty()){ t=q1.front();q1.pop(); if(t%n==0) return t; x1=t*10;x2=x1+1; mod1=x1%n;mod2=x2%n; if(!vis[mod1]){ q1.push(x1);vis[mod1]=1; } if(!vis[mod2]){ q1.push(x2);vis[mod2]=1; } } } int main() { while(scanf("%d",&n) && n) printf("%I64d\n",BFS()); return 0; }
相关文章推荐
- POJ 题目1426 Find The Multiple(DFS)
- POJ 1426 Find The Multiple(dfs)
- POJ ~ 1426 ~ Find The Multiple(DFS)
- POJ - 1426 Find The Multiple (暴力DFS)
- Find The Multiple (dfs)POJ - 1426
- POJ 1426 Find The Multiple (DFS + 构造)
- 文章标题 POJ 1426 :Find The Multiple (dfs)
- POJ1426 Find The Multiple (BFS | DFS)
- POJ-1426-Find The Multiple(BFS DFS)
- POJ 1426 Find The Multiple (DFS)
- POJ - 1426 - Find The Multiple (DFS)
- Poj 1426--Find The Multiple(bfs或dfs)
- poj 1426 Find The Multiple(dfs || 二进制枚举)
- poj 1426 Find The Multiple(DFS)
- POJ 1426 Find The Multiple(dfs)
- POJ 1426 Find The Multiple (dfs)
- POJ1426——DFS——Find The Multiple
- POJ 1426 Find The Multiple(dfs)
- POJ 1426 Find The Multiple --- BFS || DFS
- poj 1426 Find The Multiple(DFS或打表)