POJ1426-Find The Multiple-bfs
Input
Output
Sample Input
2
6
19
0
Sample Output
10
100100100100100100
111111111111111111 题意:找到只由0或1组成的小于100位的数能够整除题目给出的数据
#include<iostream>
#include<queue>
using namespace std; int n;
void bfs(int x)
{ queue<long long>Q;
long long p=;
Q.push(p);
while(!Q.empty())
{
p=Q.front();
Q.pop();
if(p%n==)
{
cout<<p<<endl;
break;
}
Q.push(p*);
Q.push(p*+);
}
return ;
} int main()
{
std::ios::sync_with_stdio(false);
while(cin>>n)
{
if(n==)
break;
else
{
bfs(n);
}
}
return ;
}
POJ1426-Find The Multiple-bfs的更多相关文章
- 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 [bfs 记录路径]
传送门 转:http://blog.csdn.net/wangjian8006/article/details/7460523 (比较好的记录路径方案) #include<iostream> ...
- POJ1426——Find The Multiple
POJ1426--Find The Multiple Description Given a positive integer n, write a program to find out a non ...
- POJ 1426 Find The Multiple --- BFS || DFS
POJ 1426 Find The Multiple 题意:给定一个整数n,求n的一个倍数,要求这个倍数只含0和1 参考博客:点我 解法一:普通的BFS(用G++能过但C++会超时) 从小到大搜索直至 ...
- POJ1426:Find The Multiple(算是bfs水题吧,投机取巧过的)
http://poj.org/problem?id=1426 Description Given a positive integer n, write a program to find out a ...
- POJ1426Find The Multiple[BFS]
Find The Multiple Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 27433 Accepted: 114 ...
- POJ1426 Find The Multiple (宽搜思想)
Find The Multiple Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 24768 Accepted: 102 ...
- ZOJ 1136 Multiple (BFS)
Multiple Time Limit: 10 Seconds Memory Limit: 32768 KB a program that, given a natural number N ...
- poj1426 Find The Multiple
Find The Multiple Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 14622 Accepted: 593 ...
- POJ 1465 Multiple (BFS,同余定理)
id=1465">http://poj.org/problem?id=1465 Multiple Time Limit: 1000MS Memory Limit: 32768K T ...
随机推荐
- scite配置文件及常用设置
在linux系统中,SciTE的用户设置文件为 ~/.SciTEUser.properties,优先级高于全局配置文件. scite是个不错的IDE工具,只是本人发现,在开发团队中和其他成员的编辑工具 ...
- php页面出现空白解决方法
查询php程序使用内存情况 $size = memory_get_usage(); file_put_contents("d:/data.php", var_export($siz ...
- HDU 5441 Travel (离线dsu)
<题目链接> 题目大意:$n$个点,$m$条边,每条边具有对应的权值,然后进行$k$次询问,每次询问给定一个值,所有权值小于等于这个的边所对应的点能够相连,问每次询问,这些能够相互到达的点 ...
- Go语言_方法和接口
方法和接口 本节课包含了方法和接口,可以用这种构造来定义对象及其行为. Go 作者组编写,Go-zh 小组翻译. https://tour.go-zh.org/methods/1 方法 Go 没有类. ...
- JVM(17)之 准备-解析-初始化
开发十年,就只剩下这套架构体系了! >>> 在类加载机制的五个阶段中,我们已经讲完了第一个阶段.剩下的四个阶段由于涉及到比较多的类文件相关的知识,现在讲了会看得很吃力,所以我们暂 ...
- docker ssh连接不上
docker ssh连接报下面的错 Last login: Thu Apr 13 09:17:23 2017 from localhost Connection to 127.0.0.1 closed ...
- mpvue 微信小程序半屏弹框(half-screen-dialog)
<template> <div> <a @click="isShow">half-screen-dialog</a> <!-- ...
- Spring 事物机制(总结)
Spring两种事物处理机制,一是声明式事物,二是编程式事物 声明式事物 1)Spring的声明式事务管理在底层是建立在AOP的基础之上的.其本质是对方法前后进行拦截,然后在目标方法开始之前创建或者加 ...
- <select multiple="multiple"> 数据回显
var names = yunying_name.split(","); for (var i = 0; i < names.length; i++) { names[i] ...
- 【串线篇】Mybatis之SSM整合
SSM:Spring+SpringMVC+MyBatis 建立Java web项目 一.导包 1).Spring: [aop核心] com.springsource.net.sf.cglib-2.2. ...