POJ 1426
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的更多相关文章
- 广搜+打表 POJ 1426 Find The Multiple
POJ 1426 Find The Multiple Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 25734 Ac ...
- POJ 1426 Find The Multiple --- BFS || DFS
POJ 1426 Find The Multiple 题意:给定一个整数n,求n的一个倍数,要求这个倍数只含0和1 参考博客:点我 解法一:普通的BFS(用G++能过但C++会超时) 从小到大搜索直至 ...
- POJ 1426 Find The Multiple(寻找倍数)
POJ 1426 Find The Multiple(寻找倍数) Time Limit: 1000MS Memory Limit: 65536K Description - 题目描述 Given ...
- POJ.1426 Find The Multiple (BFS)
POJ.1426 Find The Multiple (BFS) 题意分析 给出一个数字n,求出一个由01组成的十进制数,并且是n的倍数. 思路就是从1开始,枚举下一位,因为下一位只能是0或1,故这个 ...
- DFS/BFS(同余模) POJ 1426 Find The Multiple
题目传送门 /* 题意:找出一个0和1组成的数字能整除n DFS:200的范围内不会爆long long,DFS水过~ */ /************************************ ...
- poj 1426 Find The Multiple( bfs )
题目:http://poj.org/problem?id=1426 题意:输入一个数,输出这个数的整数 倍,且只有0和1组成 程序里写错了一个数,结果一直MLE.…… #include <ios ...
- POJ 1426 Find The Multiple(数论——中国同余定理)
题目链接: http://poj.org/problem?id=1426 Description Given a positive integer n, write a program to find ...
- 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 ...
- POJ - 1426 Find The Multiple(搜索+数论)
转载自:優YoU http://user.qzone.qq.com/289065406/blog/1303946967 以下内容属于以上这位dalao http://poj.org/problem? ...
随机推荐
- IE安全分析
IE安全问题,这个话题似乎很古老了,但是问题又是层出不穷~ 对于IE的安全,我个人认为有两点需要关注,一个是上网的安全,二个是IE解析代码的安全 对于IE上网安全,这是最基本的,也是最常用的了 附上一 ...
- 【phpcms-v9】phpcms-v9二次开发所必须知道的步骤(转载)
一.做phpcms-v9二次开发时,我们经常需要用到如下代码,所以有必须在这里注释说明一下 defined('IN_PHPCMS') or exit('No permission resources. ...
- Winform端上传图片到服务器
转载自 在winform实现文件上传到服务器 webform上传文件可能大家都写过很多,一个HtmlInputFile.PostedFile.SaveAs就搞定了,不过不知道大家有没有在winfor ...
- Samus驱动中的Document条件
今天要说一个东西就是Samus驱动里的 Document 和他的一个子类 Op 在Samus驱动的增删改查方法中都有这类的参数传递.. 大致的使用方法是这样.. MongoU.Find<Per ...
- springmvc 注解总结
1.@RequestMapping@RequestMappingRequestMapping是一个用来处理请求地址映射的注解(将请求映射到对应的控制器方法中),可用于类或方法上.用于类上,表示类中的所 ...
- 改变Vim在iTerm2中的光标
vim ~/.vimrc 添加 " Change cursor shape between insert and normal mode in iTerm2.appif $TERM_PROG ...
- PHP中的ob_start用法详解
用PHP的ob_start();控制您的浏览器cache Output Control 函数可以让你自由控制脚本中数据的输出.它非常地有用,特别是对于:当你想在数据已经输出后,再输出文件头的情况.输出 ...
- php 选择排序法
private function demo(array $arr = array()){ $len = count($arr); if ($len == 1) return $arr; else fo ...
- 7个Linux和Ubuntu下的免费CSS编辑器
一个好的编辑器是世界上所有程序员和web开发人员梦寐以求的东西.代码编辑器和集成开发环境是程序员工作时的左膀右臂.还在纠结使用什么编辑器么?下面我们将推荐7个主要用于Linux操作系统的免费CSS代码 ...
- PHP封装一个通用好用的文件上传处理类
封装一个文件上传类完成基本功能如下: 1.可上传多个或单个文件 2.上传成功返回一个或多个文件名 3.上传失败则返回每个失败文件的错误信息 上传类中的基本功能: 1.构造参数,用户可以自定义配置参数, ...