博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
HDU 4394 BFS
阅读量:7272 次
发布时间:2019-06-29

本文共 861 字,大约阅读时间需要 2 分钟。

M2%10x=N (x=0,1,2,3....)

给出N。找到最小的满足条件的M

因为:N的个位仅仅由M的个位决定。N十位由M的个位和十位决定,N的百位由M的个位十位百位决定。以此类推

全部从个位開始搜索满足条件的数字就可以

#include"stdio.h"#include "string.h"#include "math.h"#include "queue"using namespace std;__int64  flag,n;__int64  make(__int64  x,__int64  dit,__int64  num,__int64  i){    __int64  y,now,j;    y=1;    for (j=1;j
q; __int64 dit,i,cnt,x,now,num; q.push(0); dit=0; flag=-1; while (!q.empty()) { cnt=q.size(); num=n%10; dit++; n/=10; while (cnt--) { x=q.front(); q.pop(); for (i=0; i<=9; i++) { now=make(x,dit,num,i); // x之前所生成的数字,dit当前搜索到第几位,应该位应该匹配的数字,搜索当前位数字为i if (now!=-1) { q.push(now); if (n==0) { if (now

转载地址:http://yancm.baihongyu.com/

你可能感兴趣的文章
MAC 安装更新 ANT
查看>>
微软新ML框架 interpret-尝试
查看>>
创建可序列化的自定义数据结构
查看>>
ios SDWebImage
查看>>
innobackupex部分备份
查看>>
mongodb查询速度慢是什么原因?
查看>>
shell top解析
查看>>
Spring RestTemplate 详解
查看>>
HTML5编程之旅 第5站Web Workers
查看>>
oracle 性能优化 02_OWI及性能视图
查看>>
<转>MySQL5.5数据库复制搭建报错之Could not initialize maste...
查看>>
职场老人谈:Linux学习分享
查看>>
JDBC优化 -1
查看>>
RGB HSV HLS三种色彩模式转换(C语言实现)
查看>>
Find方法
查看>>
spring aop 如何切面到mvc 的controller
查看>>
Git推送tag到远端服务器
查看>>
UML依赖,关联,组合,聚合,继承,实现的关系
查看>>
CentOS下PHP 5.6编译安装
查看>>
JS数组的引用问题
查看>>