POJ 1426 Find The Multiple(dfs)
来源:互联网 发布:java怎么搭建服务器 编辑:程序博客网 时间:2024/04/30 22:47
一开始被m的位数吓到了,以为要用高精度 。 后来发现答案不会超long long,也不知道是数据水了还是本来如此。
这样就很简单了, 搜索深度最多19层,每一层只有两个决策: m*10 和m*10+1 。
细节参见代码:
#include<cstdio>#include<cstring>#include<iostream>#include<algorithm>#include<vector>#include<set>#include<cmath>using namespace std;typedef long long ll;const int mod = 1000000007;const int INF = 1000000000;const int maxn = 3000000 + 5;int n,m,T;bool dfs(ll v, int d) { if(v % n == 0) { printf("%I64d\n",v); return true; } if(d >= 19) return false; if(dfs(v*10,d+1)) return true; if(dfs(v*10+1,d+1)) return true; return false;}int main() { while(~scanf("%d",&n)&&n) { dfs(1,1); } return 0;}
0 0
- POJ 1426 Find The Multiple (DFS)
- POJ - 1426 - Find The Multiple (DFS)
- POJ 1426 Find The Multiple(dfs)
- POJ 1426 Find The Multiple(dfs)
- POJ 1426 Find The Multiple(dfs)
- poj 1426 Find The Multiple(DFS)
- POJ 1426Find The Multiple(DFS)
- POJ 1426 Find the Multiple(dfs)
- POJ-1426-Find The Multiple(DFS)
- 【DFS】poj 1426 Find The Multiple
- POJ 1426 Find The Multiple(DFS构造)
- POJ 1426 Find The Multiple (DFS + 构造)
- Poj 1426 Find The Multiple 【DFS】
- DFS-POJ-1426-Find The Multiple
- poj 1426 Find The Multiple ( dfs )
- POJ 1426 Find The Multiple(dfs)
- POJ 1426 Find The Multiple (dfs)
- POJ 1426 Find The Multiple【dfs】
- 283-e-Move Zeroes
- iOS开发------多线程编程(1)
- 替代Java类的日期和时间【 Joda Time】
- 大视野 1503 郁闷的出纳员 Splay 初步
- ns-2与TCP拥塞模拟 之四 ns-2仿真脚本中的元素
- POJ 1426 Find The Multiple(dfs)
- log4cpp
- 安卓简单开发(9)----打包APK
- R连接MySQL数据库方法
- [root@localhost zhu]# yum install vim Loaded plugins: langpacks, presto, refresh-packagekit Adding e
- 堆排序 Heap Sort
- javascript创建对象常用方法
- AJAX学习笔记
- spring 作用域之单例模式/原型模型