POJ 1426/ ZOJ 1530 Find The Multiple
2013-04-05 17:26
369 查看
直接用BFS打表了,STL的queue速度比较慢,198和99串比较长就手动了,蛋疼
#include <iostream> #include <cstdio> #include <queue> using namespace std; const int maxn=201; long long table[201]; int n; void init(){ for (int i=1;i<maxn;++i) { if(i==198){ table[i]=1111111111111111110; continue; } if(i==99){ table[i]=111111111111111111; continue; } queue<long long>q; q.push(1); while (q.size()) { long long t=q.front(); q.pop(); if(t%i==0){ table[i]=t; break; } q.push(t*10); q.push(t*10+1); } } } int main(){ init(); while (scanf("%d",&n)&&n) { printf("%lld\n",table ); } return 0; }
相关文章推荐
- [ZOJ1426 ][POJ1693] Counting Rectangles
- poj 1426 数字广搜
- POJ-1426--Find The Multiple---BFS广搜
- zoj poj 题目分类
- poj 1426 dfs~
- ZOJ 1060 (POJ 1094) Sorting It …
- poj 1426 Find The Multiple
- poj 1426 Find The Multiple
- 计算几何基础与一般模板:POJ 3675&&ZOJ 1450&&POJ 1375
- POJ-1556 & ZOJ-1721 保持下手感..话说...
- problem-1426-poj
- POJ1426-Find The Multiple
- POJ 1426 (BFS)
- zoj 1970 || poj 1936 All in All(水题,想说爱你不容易 = =)
- 【DFS】poj 1426 Find The Multiple
- ZOJ-1360 || POJ-1328——Radar Installation
- zoj 1926 || poj 2328 Guessing Game(水~)
- POJ 1562 Oil Deposits (HDU 1241 ZOJ 1562) DFS
- POJ 1426 Find The Multiple(BFS)
- POJ 2258 ZOJ 1947 UVA 539 The Settlers of Catan