poj 1426 Find The Multiple( bfs )
2013-08-26 20:57
483 查看
题目:http://poj.org/problem?id=1426
题意:输入一个数,输出这个数的整数 倍,且只有0和1组成
程序里写错了一个数,结果一直MLE.……
还 有用同余模定理做的
(a*b)%n = (a%n *b%n)%n
(a+b)%n = (a%n +b%n)%n
地址:/article/1968908.html
题意:输入一个数,输出这个数的整数 倍,且只有0和1组成
程序里写错了一个数,结果一直MLE.……
#include <iostream> #include<cstdio> #include<cstring> #include<cstdlib> #include<stack> #include<queue> #include<iomanip> #include<cmath> #include<map> #include<vector> #include<algorithm> using namespace std; long long a; void bfs() { queue<long long>q; int i,j; long long x=1,pos; q.push(x); while(!q.empty()) { pos=q.front(); q.pop(); for(i=0; i<2; i++) { x=pos*10+i; if(x%a==0) { cout<<x<<endl; return; } q.push(x); } } } int main() { int i,j; while(cin>>a&&a) { if(a==1) { cout<<"1"<<endl; continue; } bfs(); } return 0; }
还 有用同余模定理做的
(a*b)%n = (a%n *b%n)%n
(a+b)%n = (a%n +b%n)%n
地址:/article/1968908.html
相关文章推荐
- Find The Multiple-POJ-1426-BFS
- POJ1426-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 搜索)
- poj1426 - Find The Multiple [bfs 记录路径]
- POJ1426,Find The Multiple,bfs...注意类型 5兆内存过了...
- poj1426——Find The Multiple(BFS)
- POJ - 1426 Find The Multiple(15.10.10 搜索专题)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)两种解法
- Find The Multiple (poj 1426 bfs)
- POJ 1426-Find The Multiple(bfs)
- D - Find The Multiple POJ - 1426 ——DFS || BFS
- Find The Multiple (poj 1426 bfs)
- POJ训练计划1426_Find The Multiple(BFS)