#include<stdio.h>
#include<stdlib.h>
#include<string.h>
bool found;
void DFS(unsigned __int64 t ,int n,int k)
{
if(found)
return ;//如果已经发现了答案就没搜的必要了
if(t%n==0)
{//发现答案,输出,标记变量该true
printf("%I64u\n",t);
found=true;
return ;
}
if(k==19)//到第19层,回溯
return ;
DFS(t*10,n,k+1); //搜索×10
DFS(t*10+1,n,k+1); //搜索×10+1
}
int main()
{
int n;
while(scanf("%d",&n))
{
found=false;//标记变量,当为true代表搜到了题意第一的m
DFS(1,n,0); //从1开始搜n的倍数,第三个参数代表搜的层数,当到第19层时返回(因为第20层64位整数存不下)
}
return 0;
}

【搜索】 Find The Multiple的更多相关文章

  1. Cordova与现有框架的结合,Cordova插件使用教程,Cordova自定义插件,框架集成Cordova,将Cordova集成到现有框架中

    一.框架集成cordova 将cordova集成到现有框架中 一般cordova工程是通过CMD命令来创建一个工程并添加Android.ios等平台,这样的创建方式可以完整的下载开发过程中所需要的的插 ...

  2. [深度优先搜索] POJ 1426 Find The Multiple

    Find The Multiple Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 28550   Accepted: 118 ...

  3. poj 1426 Find The Multiple 搜索进阶-暑假集训

    E - Find The Multiple Time Limit:1000MS     Memory Limit:10000KB     64bit IO Format:%I64d & %I6 ...

  4. POJ1426-Find The Multiple(搜索)

    Find The Multiple Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 42035   Accepted: 176 ...

  5. 【搜索、bfs】Find The Multiple

    Problem   Given a positive integer n, write a program to find out a nonzero multiple m of n whose de ...

  6. Find The Multiple 分类: 搜索 POJ 2015-08-09 15:19 3人阅读 评论(0) 收藏

    Find The Multiple Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 21851 Accepted: 8984 Sp ...

  7. HDU 4294 Multiple(搜索+数学)

    题意: 给定一个n,让求一个M,它是n个倍数并且在k进制之下 M的不同的数字最少. 思路: 这里用到一个结论就是任意两个数可以组成任何数的倍数.知道这个之后就可以用搜索来做了.还有一个问题就是最多找n ...

  8. POJ Find The Multiple 1426 (搜索)

    Find The Multiple Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 22576   Accepted: 929 ...

  9. poj 1426 Find The Multiple (简单搜索dfs)

    题目: Given a positive integer n, write a program to find out a nonzero multiple m of n whose decimal ...

  10. POJ - 1426 Find The Multiple(搜索+数论)

    转载自:優YoU  http://user.qzone.qq.com/289065406/blog/1303946967 以下内容属于以上这位dalao http://poj.org/problem? ...

随机推荐

  1. 使用fckeditor上传多张图片

    流程: 1.使用fck上传图片到后台 2.后台上传图片到服务器端 3.服务器端返回上传信息 1.jsp页面 <script type="text/javascript"> ...

  2. oracle wm_concat() 返回空

    参考 https://www.cnblogs.com/zengweiming/archive/2013/11/20/3433642.html select wm_concat(to_char(str) ...

  3. CentOS 查看是否安装软件包

    1. rpm包安装的,可以用rpm -qa看到,如果要查找某软件包是否安装,用 rpm -qa | grep "软件或者包的名字" 2. deb包安装的,可以用dpkg -l能看到 ...

  4. console报错:No mapping found for HTTP request with URI(xxx)

    console报错:No mapping found for HTTP request with URI(xxx) 报错可能原因: 1;contorl未加载成功 2;资源访问失败(所有访问全部被Dis ...

  5. 【laravel VS lumen】

    读取项目的配置信息 读取config文件database.php中的default属性信息 laravel:config('database.default'); lumen:app()->co ...

  6. unitest中HTML测试报告的优化

    简介: 为每一个测试用例添加说明,那么将会使测试报告更加易读,工作中汇报数据的技巧 其实就是添加u“msg”即可 # -*- coding:UTF-8 -*- __autor__ = 'zhouli' ...

  7. layer使用

    1引入js <script src="${pageContext.request.contextPath }/js/jquery-1.9.1.min.js" type=&qu ...

  8. ubuntu系统ssh遇到port 22:No route to host问题

    ssh遇到这个port 22:No route to host这个问题 检查防火墙状态 (iptables -L) 检查ssh状态 (ps -elf |grep ssh) 检查网络状态(换根网线)

  9. 纯css实现div中未知尺寸图片的垂直居中

    1.淘宝的方法 在曾经的"淘宝UED招聘"中有这样一道题目: “使用纯CSS实现未知尺寸的图片(但高宽都小于200px)在200px的正方形容器中水平和垂直居中.” 当然出题并不是 ...

  10. Android Studio 检查Top Activity

    public void CheckTop(String packagename,int casenum) { Context context = getBaseContext(); ActivityM ...