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 ...
随机推荐
- spring-第九篇之高级依赖关系配置
1.关于配置文件一些使用 组件与组件之间的耦合,采用依赖注入管理:基本类型的成员变量值,应该直接在代码中设置. 2.获取其他bean的属性值 PorpertyPathFactoryBean用来获取目标 ...
- luoguP1312 Mayan游戏 题解(NOIP2011)
luoguP1312 Mayan游戏 题目 #include<bits/stdc++.h> #define ll long long #define rg register #define ...
- 2019牛客暑期多校训练营(第二场) - F - Partition problem - 枚举
https://ac.nowcoder.com/acm/contest/882/F 潘哥的代码才卡过去了,自己写的都卡不过去,估计跟评测机有关. #include<bits/stdc++.h&g ...
- android 完全退出应用程序(经过严格验证)
今天解决了如何彻底结束Android应用程序的方法.网上有很多的参考方法,什么finish():android.os.Process.killProcess(android.os.Process.my ...
- JAVA-第一期学习(上)
前言 果然,flag这个东西不能随便立,在我立志要学习java的第4天,我终于打开了我的eclipse.. 本章学习的内容是红框,第一期学习.真好,7月份需要学习完的东西,现在连helloworld还 ...
- rpmbuild - 构建 RPM 打包
SYNOPSIS 构建打包: rpmbuild {-ba|-bb|-bp|-bc|-bi|-bl|-bs} [rpmbuild-options] SPECFILE ... rpmbuild {-ta| ...
- html/css 图片展示效果
demo.html <!DOCTYPE html> <html lang="en"> <head> <meta charset=" ...
- Hadoop搭建完全分布式
ubuntu系统下: https://blog.csdn.net/u014636511/article/details/80171002 centos系统下: https://blog.csdn.ne ...
- 【leetcode】553. Optimal Division
题目如下: 解题思路:这是数学上的一个定理.对于x1/x2/x3/..../xN的序列,加括号可以得到的最大值是x1/(x2/x3/..../xN). 代码如下: class Solution(obj ...
- 英语单词cylindern
cylindern 来源——fdisk -l [root@centos65 ~]# fdisk -l Disk /dev/sda: 214.7 GB, 214748364800 bytes 255 h ...