http://poj.org/problem?id=1426

一道广搜的题目。

题意就是给你一个n,要你求出n的倍数中,只存在0和1的那个数字

所谓的只存在0和1,那么就是某个数的十倍或者十倍+1,而那个最开始的数应该是1。

 Memory :5504K G++ runtime:391MS
#include <iostream>
#include <queue> using namespace std; int n; queue <long long >s; void bfs(int n)
{
while(!s.empty())
s.pop();
s.push();
while(!s.empty())
{
long long now;
now=s.front();
s.pop();
if(now%n==)
{
cout<<now<<endl;
return ;
}
s.push(now*);
s.push(now*+);
}
} int main()
{
while(cin>>n&&n)
{
bfs(n);
}
return ;
}

POJ 1426的更多相关文章

  1. 广搜+打表 POJ 1426 Find The Multiple

    POJ 1426   Find The Multiple Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 25734   Ac ...

  2. POJ 1426 Find The Multiple --- BFS || DFS

    POJ 1426 Find The Multiple 题意:给定一个整数n,求n的一个倍数,要求这个倍数只含0和1 参考博客:点我 解法一:普通的BFS(用G++能过但C++会超时) 从小到大搜索直至 ...

  3. POJ 1426 Find The Multiple(寻找倍数)

    POJ 1426 Find The Multiple(寻找倍数) Time Limit: 1000MS    Memory Limit: 65536K Description - 题目描述 Given ...

  4. POJ.1426 Find The Multiple (BFS)

    POJ.1426 Find The Multiple (BFS) 题意分析 给出一个数字n,求出一个由01组成的十进制数,并且是n的倍数. 思路就是从1开始,枚举下一位,因为下一位只能是0或1,故这个 ...

  5. DFS/BFS(同余模) POJ 1426 Find The Multiple

    题目传送门 /* 题意:找出一个0和1组成的数字能整除n DFS:200的范围内不会爆long long,DFS水过~ */ /************************************ ...

  6. poj 1426 Find The Multiple( bfs )

    题目:http://poj.org/problem?id=1426 题意:输入一个数,输出这个数的整数 倍,且只有0和1组成 程序里写错了一个数,结果一直MLE.…… #include <ios ...

  7. POJ 1426 Find The Multiple(数论——中国同余定理)

    题目链接: http://poj.org/problem?id=1426 Description Given a positive integer n, write a program to find ...

  8. POJ 1426 - Find The Multiple - [DP][BFS]

    题目链接:http://poj.org/problem?id=1426 Given a positive integer n, write a program to find out a nonzer ...

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

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

随机推荐

  1. 初识ActionScript

    <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:fx="h ...

  2. Makefile的学习笔记

    Makefile的学习笔记 标签: makefilewildcard扩展includeshellfile 2012-01-03 00:07 9586人阅读 评论(2) 收藏 举报  分类: Linux ...

  3. 2015年11月30日 spring初级知识讲解(一)装配Bean

    序,Spring的依赖注入是学习spring的基础.IOC为控制反转,意思是需要的时候就由spring生成一个,而不是先生成再使用. 写在前面 Spring提供面向接口编程,面向接口编程与依赖注入协作 ...

  4. EF方便的添加一条信息...

    //刚开始通过EF添加数据都是这样的...↓ var db = new DBEntities() T_User t_userinfo = new T_User() { Type = "typ ...

  5. python文件I/O(转)

    Python 文件I/O 本章只讲述所有基本的的I/O函数,更多函数请参考Python标准文档. 打印到屏幕 最简单的输出方法是用print语句,你可以给它传递零个或多个用逗号隔开的表达式.此函数把你 ...

  6. 如何设计PHP业务模块(函数/方法)返回结果的结构?

    如题:如何设计业务模块返回结果的结构? 一个业务函数/方法执行后,对外输出数据的结构通常有以下几种: 1.返回数字,如 成功时返回 0,失败时返回 -1,有的还会用一个全局变量输出错误信息: < ...

  7. 自己动手开发jQuery插件

    因为工作需要,所以这几天琢磨了一下关于jQuery插件开发的问题,经过一天鏖战,终于完成自己动手做的第一个jQuery插件,对于俺这种见了css就蛋疼菊紧的人来说,一天时间8小时,保守估计有5个小时在 ...

  8. javascript 正则表达式使用

    切记:js 正则表达式无需用双引号,正则表达式不是字符串. 参考网址:http://www.w3school.com.cn/jsref/jsref_obj_regexp.asp 个人用于查找字条串匹配 ...

  9. memcache安装

    windows下访问 http://pecl.php.net/package/memcache/3.0.8/windows 下载对应版本memcache的dll文件添加到php目录ext下 PHP.i ...

  10. 分析Masonry

    一. 继承关系 1.MASConstraint (abstract) MASViewContraint MASComposisionConstraint 2. UIView NSLayoutConst ...