poj 1465 Multiple 静态节点+余数判重+非STL队列的广搜
来源:互联网 发布:淘宝流量接单任务平台 编辑:程序博客网 时间:2024/05/01 23:09
//poj 1465//sep9#include <iostream>#include <algorithm>using namespace std;int n,m,p;int num[16],vis[8192];struct NODE{int dig,r,pre; }Q[8192];void print(int x){if(x!=-1){print(Q[x].pre);printf("%d",Q[x].dig);}}void bfs(){int l=0,r=0;memset(vis,0,sizeof(vis));for(int i=1;i<=m;++i){if(num[i]==0) continue;NODE p;p.dig=num[i];p.pre=-1;p.r=num[i]%n;Q[r++]=p;}while(l<r){NODE now=Q[l];if(now.r==0){print(l);puts("");return;}for(int i=1;i<=m;++i){NODE nxt;nxt.dig=num[i],nxt.r=(10*now.r+num[i])%n,nxt.pre=l;if(!vis[nxt.r]){Q[r++]=nxt;vis[nxt.r]=1;}}l++;}puts("0");}int main(){while(scanf("%d",&n)==1){scanf("%d",&m);for(int i=1;i<=m;++i)scanf("%d",&num[i]);sort(num+1,num+1+m);if(n==0){puts("0");continue;}bfs();}return 0;}
0 0
- poj 1465 Multiple 静态节点+余数判重+非STL队列的广搜
- POJ 1465 Multiple BFS + 余数判重
- POJ 1465/ ZOJ 1136 : Multiple - BFS,余数判重
- poj 1465 bfs+余数判重
- Poj1465 Multiple(BFS+余数判重)
- HDU 4474&&POJ 1465 BFS&&余数判重
- hdu 4474 Yet Another Multiple Problem (余数判重 + BFS)
- POJ 1465 Multiple (广搜,哈希判重)
- poj 3131 Cubic Eight-Puzzle 双向广搜 Hash判重
- hdu 2579 余数判重
- [bfs+余数判重+路径记录] hdu 4474 Yet Another Multiple Problem
- 搜索_Poj 1465_剪枝_余数判重
- POJ 1426 Find The Multiple (广搜)
- 利用stl的map判重poj3087
- pku 1077 Eight【八数码、广搜、hash判重】
- UVA 1533 - Moving Pegs (广搜+hash判重)
- poj1465Multiple(经典BFS+余数判重)
- POJ-1426--Find The Multiple---BFS广搜
- Apache ab 压力测试出现 Failed requests
- ⾃自定义cell的步骤
- 51Nod 1376 最长递增子序列的数量(dp+树状数组)
- Git使用
- Masonry使用
- poj 1465 Multiple 静态节点+余数判重+非STL队列的广搜
- JNI
- [python] 使用scikit-learn工具计算文本TF-IDF值
- UVA - 1374 Power Calculus(IDA*+剪枝)
- 一个程序员的跨洋找工作分享
- PMC推出Smart系列解决方案 提供高效数据中心连接
- Leetcode 经典题目题解
- 一篇文章学会springMVC
- POJ 3280 解题报告