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? ...
随机推荐
- GoLang之基础
GoLang之基础 Go是一种并发的.带垃圾回收的.快速编译的语言. 经典的"hello world"入门: package main import "fmt" ...
- 查找“CDN、负载均衡、反向代理”等大型网络真实IP地址的方法
首先,CDN.负载均衡.反向代理还分为很多层,有时查出来的是最外层的 CDN 服务器群,真实的机器是不对外开放的,类似这样的: 用户 → CDN 网络 → 一台或多台真实机器 ↗ CDN Server ...
- 跟着ttlsa一起学zabbix监控呗
本章转载至:http://www.ttlsa.com/zabbix/follow-ttlsa-to-study-zabbix/ 虽然接触zabbix时间很长,但是中间相当一段时间没去配置,这次算是重新 ...
- Java8初体验(一)lambda表达式语法
感谢同事[天锦]的投稿.投稿请联系 tengfei@ifeve.com 本文主要记录自己学习Java8的历程,方便大家一起探讨和自己的备忘.因为本人也是刚刚开始学习Java8,所以文中肯定有错误和理解 ...
- 新浪微博客户端(36)-自定义带placeholder的TextView
iOS 上自带的UITextView竟然不能设置placeholder,但是UITextView却可以,我也真是醉了.没办法了,自己写一个 DJTextView.h #import <UIKit ...
- HTML5音乐播放器(最新升级改造加强版)
最近么,单位里面么老不顺心的,公司一直催要程序员要PHP,然后本宅好不容易推荐了一个,我日嘞,最后待遇变成1.3,吾师最后也同意1.3W,然后还说要考虑... 尼玛,4年多5年不到一点的工作经验,前端 ...
- 绕过HR破门而入的求职智慧
以往我们在网上看到的很多求职文章或指导性纲领,譬如啥自信.做功课.良好形象.华丽的简历.工作经验.口才啥的,其实到了21世纪尤其是互联网高速发展的今天,前面这些技巧就显得无比空洞: 1.因为自信谁都可 ...
- 清北国庆day1 (脑)残
(留坑) /* 不知道为什要找的循环节TM这么长 */ #include<cstdio> #include<cstdlib> #include<cstring> u ...
- Todd's Matlab讲义第6讲:割线法
割线法 割线法求解方程\(f(x)=0\)的根需要两个接近真实根\(x^\*\)的初值\(x_0\)和\(x_1\),于是得到函数\(f(x)\)上两个点\((x_0,y_0=f(x_0))\)和\( ...
- 数论只会GCD。。。
一些关于GCD的代码.... #include <iostream> #include <cstdio> #include <cstring> using name ...