poj 1426
来源:互联网 发布:soaoffice java 编辑:程序博客网 时间:2024/05/29 11:23
继续简单题 bfs
搜索十进制数里面只有0和1的能够整除输入数的数字
long long型
#include <iostream>#include <sstream>#include <cstdio>#include <cstring>#include <cmath>#include <string>#include <vector>#include <set>#include <cctype>#include <algorithm>#include <cmath>#include <deque>#include <queue>#include <map>#include <queue>#include <list>#include <iomanip>using namespace std; //////#define INF 0xffffff7#define maxn 50#define max(a,b)(a>b?a:b)///long long tmp, ans;queue<long long> stk;int n;void bfs(){int i, j;while(!stk.empty())stk.pop();tmp = 1;stk.push(tmp);while(!stk.empty()){tmp = stk.front();stk.pop();if(tmp % n == 0){ans = tmp;break;}stk.push(tmp * 10);stk.push(tmp * 10 + 1);}}int main(){///int i, j, k;while (1){cin >> n;if(n == 0)break;bfs();cout << ans << endl;}/// return 0;}
- poj 1426
- poj 1426
- POJ 1426
- POJ 1426
- poj 1426
- poj 1426
- poj 1426
- POJ 1426
- poj-1426
- poj 1426
- poj 1426
- 1426POJ
- poj 1426
- poj 1426
- poj--1426
- POJ 1426
- POJ 1426
- poj 1426
- Hibernate映射类型
- maven2创建一个eclipse工程,设置M2_REPO
- JDBC 连接数据库的 基本操作 增 ,查
- Android 自定义ProgressDialog
- 随笔
- poj 1426
- cisco Dhcp 实验
- SQL SERVER中动态执行SQL
- linux常用命令【分类导航链接,很全】
- UIPanGestureRecognizer类——为view添加手势
- 傻孩子。痛了?放手吧:伤感日志
- Derby入门
- 五十六、基础框架(十四)创建 地址簿-4
- 五十七、基础框架(十五)创建 地址簿-5