POJ 1426 Find The Multiple
来源:互联网 发布:汉高薪资待遇 知乎 编辑:程序博客网 时间:2024/06/11 08:57
因为是special judge, 找出一组解即可。用DFS, 记得及时退出。同时unsigned long long足够表示最后的答案, 不需要使用高精度。
#include <iostream>#include <cstdio>using namespace std;int flag, n;int dfs(unsigned long long a, int step){if (flag == 1 || step == 19)return 0;else if (a % n == 0){printf("%lld\n", a);flag = 1;return 1;}else{if (!dfs(a * 10, step + 1)){dfs(a * 10 + 1, step + 1);}}}int main(){while (scanf("%d", &n), n){flag = 0;dfs(1, 0);}}
0 0
- poj 1426 Find The Multiple
- Poj 1426 Find The Multiple
- POJ 1426 Find the Multiple
- poj 1426Find The Multiple
- POJ 1426 Find The Multiple
- POJ 1426 Find The Multiple
- POJ 1426 Find The Multiple
- POJ 1426 Find The Multiple
- poj - 1426 - Find The Multiple
- POJ 1426 Find The Multiple
- POJ-1426-Find The Multiple
- POJ 1426 Find The Multiple
- POJ 1426 Find The Multiple
- POJ 1426 Find The Multiple
- POJ 1426 Find The Multiple
- POJ 1426 Find The Multiple
- poj 1426 Find The Multiple
- POJ 1426 Find The Multiple
- Linux下Redis开机自启(Centos)
- Bootstrap 3 + MVC 5 - validation css tips
- 灾难的一天:“SSL_connect SYSCALL”和“the scheme https does not accept registry part”两种错误
- IOS开发记录(一)
- 渐变动画/按钮/图片拉伸/copy/KVC/KVO
- POJ 1426 Find The Multiple
- 徒步一千里 (1930) (長津惠山)
- golang---利用反射机制对结构体进行循环赋值
- POJ 2243 Knight Moves
- Sqoop_1. 基本架构及数据操作 -- 待完善
- POJ 3620 Avoid The Lakes
- 【Leetcode】Search a 2D Matrix
- 一些笔记
- 果然还是不够努力是吗?