POJ1426Find The Multiple[BFS]
| Time Limit: 1000MS | Memory Limit: 10000K | |||
| Total Submissions: 27433 | Accepted: 11408 | Special Judge | ||
Description
Input
Output
Sample Input
2
6
19
0
Sample Output
10
100100100100100100
111111111111111111
Source
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <queue>
using namespace std;
const int N=1e6,INF=1e9;
typedef long long ll;
ll n;
queue<ll>q;
ll bfs(){
ll x;
while(!q.empty()) q.pop();
q.push();
while(!q.empty()){
x=q.front();
q.pop();
if(x%n==) return x;
q.push(x*);
q.push(x*+);
}
}
int main(){
while(~scanf("%lld",&n)){
if(n==) break;
printf("%lld\n",bfs());
}
return ;
}
POJ1426Find The Multiple[BFS]的更多相关文章
- POJ 1426 Find The Multiple --- BFS || DFS
POJ 1426 Find The Multiple 题意:给定一个整数n,求n的一个倍数,要求这个倍数只含0和1 参考博客:点我 解法一:普通的BFS(用G++能过但C++会超时) 从小到大搜索直至 ...
- ZOJ 1136 Multiple (BFS)
Multiple Time Limit: 10 Seconds Memory Limit: 32768 KB a program that, given a natural number N ...
- POJ 1465 Multiple (BFS,同余定理)
id=1465">http://poj.org/problem?id=1465 Multiple Time Limit: 1000MS Memory Limit: 32768K T ...
- poj 1426 Find The Multiple (bfs 搜索)
Find The Multiple Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 18012 Accepted: 729 ...
- POJ1426-Find The Multiple(搜索)
Find The Multiple Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 42035 Accepted: 176 ...
- TOJ3031: Multiple bfs
3031: Multiple Time Limit(Common/Java):2000MS/6000MS Memory Limit:65536KByte Total Submit: 60 ...
- POJ1426 Find The Multiple —— BFS
题目链接:http://poj.org/problem?id=1426 Find The Multiple Time Limit: 1000MS Memory Limit: 10000K Tota ...
- poj1426--Find The Multiple(广搜,智商题)
Find The Multiple Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 18527 Accepted: 749 ...
- POJ1426Find The Multiple
http://poj.org/problem?id=1426 题意 : 输入一个数n,找n的倍数m,这个m所满足的条件是,每一位数只能由0或1组成,在题目的旁边用红色的注明了Special Judge ...
随机推荐
- Linux下Oracle重启问题
一.切换成oracle用户 $ su - oracle 注意:不要写成“su oracle ”不然是没办法使用下面的命令的. 如下所示:将会报:command not found的错误 二.使用命令 ...
- JavaScript事件机制——细思极恐
JavaScript事件机制,也有让人深思的东西.在一开始未深入了解,我头脑里有几个问题发出: 1. 自下而上(冒泡)事件怎么写,自上而下(捕获)又是怎么写? 2. 捕获型和冒泡型同时设置,谁生效? ...
- spring(4)——自动装配
set注入和构造注入有时在做配置时比较麻烦.所以框架为了提高开发效率,提供自动装配功能,简化配置.spring框架式默认不支持自动装配的,要想使用自动装配需要修改spring配置文件中<bean ...
- 送给我的朋友——Cry on my shoulder
If the hero never comes to you如果你的真命天子仍未来到 If you need someone you"re feeling blue如果你情绪低落需要有人陪伴 ...
- OpenGL中旋转平移缩放等变换的顺序对模型的影响
l 前提: 0x01. 假设绘制顶点的语句为Draw Array,变换的语句(旋转.平移.缩放)为M,而 M0; M1; M2; Draw Array; 则称对Array先进行M2再进行M1.M0 0 ...
- 移动web开发介绍——浏览器
前段时间了解学习了一下<移动Web手册>,觉得真的需要这种不是偏向技术.框架或工具的书籍,只是单纯的讲解一些关于移动Web最基本的知识.正好今天整理一部分之前学习过的内容,记录和分享,也方 ...
- SharePoint 2013 新建项目字段自动加载上次保存值
1.点击进入NewForm.aspx页面,编辑页面,插入Script Editor WebPart,如下图: 2.插入后如下图,拖动AutoRecord WebPart到脚本编辑器上面,防止因为加载顺 ...
- iOS开发-canOpenURL: failed for URL: "xx" - error:"This app is not allowed to query for scheme xx"
转载自:http://www.jianshu.com/p/e38a609f786e
- tableView的footerView下面的颜色修改、限制文本框的输入字数
- UILabel用法
// UILabel -> UIView // UILabel用来显示文字内容 //创建一个Label,一般都直接通过initWithFrame确定位置跟大小 UILabel *lb = [[U ...