POJ-1426 (Find The Multiple) bfs
2018-03-04 21:10
369 查看
Find The Multiple
#include <iostream> #include <cstdio> #include <queue> using namespace std; typedef unsigned long long ll; struct _Node{ int depth; ll val; _Node(){ } _Node(int _depth, ll _val) { depth = _depth; val = _val; } }; void bfs(int t) { queue<_Node> q; q.push(_Node(0, 1)); while(!q.empty()){ _Node x = q.front(); q.pop(); //cout << x.val << endl; if(x.depth == 19) return ; if(x.val % t == 0) { printf("%I64u\n", x.val); return ; } q.push(_Node(x.depth + 1, x.val * 10)); q.push(_Node(x.depth + 1, x.val * 10 + 1)); } } int main() { int t; while(scanf("%d", &t) != EOF && t) { bfs(t); } return 0; }
相关文章推荐
- Poj 1426--Find The Multiple(bfs或dfs)
- POJ1426,Find The Multiple,bfs...注意类型 5兆内存过了...
- poj 1426 Find The Multiple(bfs)
- POJ 1426 Find The Multiple(同余模定理优化双入口BFS)
- POJ 1426 Find The Multiple(简单搜索bfs)
- POJ 1426 Find The Multiple(BFS)
- POJ 1426 Find The Multiple(BFS 同余模定理)
- POJ-1426-Find The Multiple(BFS DFS)
- POJ - 1426 Find The Multiple(15.10.10 搜索专题)bfs
- Find The Multiple (poj 1426 bfs)
- 【原】 POJ 1426 Find The Multiple BFS搜索 解题报告
- Find The Multiple (poj 1426 bfs)
- poj 1426 Find The Multiple(bfs)
- POJ 1426 Find The Multiple (BFS基础)
- POJ-1426-Find The Multiple【BFS】
- POJ 1426 Find The Multiple(BFS 水~)
- D - Find The Multiple POJ - 1426 ——DFS || BFS
- poj1426 - Find The Multiple [bfs 记录路径]
- POJ训练计划1426_Find The Multiple(BFS)
- poj 1426 Find The Multiple(bfs)