POJ1426——Find The Multiple
POJ1426——Find The Multiple
Description
Input
Output
Sample Input
2
6
19
0
Sample Output
10
100100100100100100
111111111111111111
代码:
#include<iostream>
#include<bits/stdc++.h>
#include<queue>
using namespace std; void BFS(int x){
queue<int> q ;
q.push(1);
int y;
while (!q.empty())
{
y=q.front();
q.pop();
for (int i = 0; i < 2; i++)
{
if (i==0) q.push(y*10);
else
q.push(y*10+1);
if (y%x==0)
{
cout<<y<<endl;
return ;
} }
}
} int main(){
int x;
while ((cin>>x)&&x)
{
BFS(x);
}
}
POJ1426——Find The Multiple的更多相关文章
- POJ1426 Find The Multiple (宽搜思想)
Find The Multiple Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 24768 Accepted: 102 ...
- poj1426 Find The Multiple
Find The Multiple Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 14622 Accepted: 593 ...
- poj1426 Find The Multiple(c语言巧解)
Find The Multiple Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 36335 Accepted: 151 ...
- POJ1426:Find The Multiple(算是bfs水题吧,投机取巧过的)
http://poj.org/problem?id=1426 Description Given a positive integer n, write a program to find out a ...
- 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 (DFS)
题目: Find The Multiple Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 41845 Accepted: ...
- POJ1426 Find The Multiple 解题报告
参考:http://www.cnblogs.com/ACShiryu/archive/2011/07/24/2115356.html #include <iostream> #includ ...
- poj1426 - Find The Multiple [bfs 记录路径]
传送门 转:http://blog.csdn.net/wangjian8006/article/details/7460523 (比较好的记录路径方案) #include<iostream> ...
- POJ1426——Find The Multiple (简单搜索+取余)
题意: 给一个数n,让你找出一个只有1,0,组成的十进制数,要求是找到的数可以被n整除. 用DFS是搜索 当前位数字 (除最高位固定为1),因为每一位都只有0或1两种选择,换而言之是一个双入口BFS. ...
随机推荐
- 关于Algorithm in Nutshell源代码
获取源码包 "Algorithm in Nutshell"的源码包ADK-1.0.zip在这本书主页上"Download Example Code"页面的Rel ...
- Haskell Interactive Development in Emacs
Installation Following haskell-mode. Use MELPA repository: add the following into ~/.emacs (require ...
- FSM自动售货机 verilog 实现及 code 细节讲解
1.题目: 饮料1.5 元, 可投入硬币1 元 0.5 元,输出饮料 零钱 2. 画出状态机. 3.仿真结果:coin=1 --> 0.5 元 coin=2-->1元 4.关键代码分析: ...
- MaterialDesign Or ComboBox 联动查询
<ComboBox Width="200" Height="30" x:Name="ComboxName" Text="{B ...
- Android模块化开发实践
一.前言 随着业务的快速发展,现在的互联网App越来越大,为了提高团队开发效率,模块化开发已经成为主流的开发模式.正好最近完成了vivo官网App业务模块化改造的工作,所以本文就对模块化开发模式进行一 ...
- DG:11.2.0.4 RAC在线duplicate恢复DG
1.环境介绍 测试环境, 在一个双节点的RAC上使用duplicate搭建DG,使用在线的方式搭建 主机 IP 操作系统 实例 db_name db_unique_name db_version 配置 ...
- docker部署elasticsearch-+-Kibana(6-8)-+-SpringBoot-2-1-6
elasticsearch快速开始 docker run -d --name elasticsearch --net somenetwork -p 9200:9200 -p 9300:9300 -e ...
- WPF 中的 经典的ModelView 通知页面更新 UI
view model ------------------------------------------------------------------------------ using HPCo ...
- 多线程编程<五>
1 /** 2 * 中断线程:当线程由于调用sleep(),join(),wait()而暂停时,如果中断它,则会收到一个InterruptedException异常. 3 * 调用Thread.isI ...
- @RequestParam注解的详细介绍
@RequestParam (org.springframework.web.bind.annotation.RequestParam)用于将指定的请求参数赋值给方法中的形参. 有三个属性: (1)v ...