POJ1426——Find The Multiple

Description

Given a positive integer n, write a program to find out a nonzero multiple m of n whose decimal representation contains only the digits 0 and 1. You may assume that n is not greater than 200 and there is a corresponding m containing no more than 100 decimal digits.

Input

The input file may contain multiple test cases. Each line contains a value of n (1 <= n <= 200). A line containing a zero terminates the input.

Output

For each value of n in the input print a line containing the corresponding value of m. The decimal representation of m must not contain more than 100 digits. If there are multiple solutions for a given value of n, any one of them is acceptable.

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的更多相关文章

  1. POJ1426 Find The Multiple (宽搜思想)

    Find The Multiple Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 24768   Accepted: 102 ...

  2. poj1426 Find The Multiple

    Find The Multiple Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 14622   Accepted: 593 ...

  3. poj1426 Find The Multiple(c语言巧解)

    Find The Multiple Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 36335   Accepted: 151 ...

  4. POJ1426:Find The Multiple(算是bfs水题吧,投机取巧过的)

    http://poj.org/problem?id=1426 Description Given a positive integer n, write a program to find out a ...

  5. POJ1426 Find The Multiple —— BFS

    题目链接:http://poj.org/problem?id=1426 Find The Multiple Time Limit: 1000MS   Memory Limit: 10000K Tota ...

  6. poj1426 Find The Multiple (DFS)

    题目: Find The Multiple Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 41845   Accepted: ...

  7. POJ1426 Find The Multiple 解题报告

    参考:http://www.cnblogs.com/ACShiryu/archive/2011/07/24/2115356.html #include <iostream> #includ ...

  8. poj1426 - Find The Multiple [bfs 记录路径]

    传送门 转:http://blog.csdn.net/wangjian8006/article/details/7460523 (比较好的记录路径方案) #include<iostream> ...

  9. POJ1426——Find The Multiple (简单搜索+取余)

    题意: 给一个数n,让你找出一个只有1,0,组成的十进制数,要求是找到的数可以被n整除. 用DFS是搜索 当前位数字 (除最高位固定为1),因为每一位都只有0或1两种选择,换而言之是一个双入口BFS. ...

随机推荐

  1. Dired Mode in Emacs

    Start up Dired mode: C-x d; (List dirs: C-x C-d) Hide Dired mode window: q; Mark Mark (for group man ...

  2. GO语言安装以及国内镜像

    首先,下载GO语言,国内的话用 Go下载 - Go语言中文网 - Golang中文社区 (studygolang.com) 可能会快一点 然后根据自己的系统选择下载的包,我是win10,就选go1.1 ...

  3. ECDSA—模加减模块

    如果a,b GF(P),则加法运算a+b=r (mod p),其中r满足0<r<p-1,即a+b除以p的余数,该操作成为模p加法.对于模减运算可以视为另类的模加运算,即a+(-b)=k ( ...

  4. miniFTP项目实战二

    项目简介: 在Linux环境下用C语言开发的Vsftpd的简化版本,拥有部分Vsftpd功能和相同的FTP协议,系统的主要架构采用多进程模型,每当有一个新的客户连接到达,主进程就会派生出一个ftp服务 ...

  5. CGO入门和OCR文字识别(非第三方API,有源码,效果好)实战

    这是我参与8月更文挑战的第5天,活动详情查看:8月更文挑战 系列文章见: [第四天] GDB调试指南:C++中如何调试生产环境的程序? [第三天] IM敏感词算法原理和实现 [第二天] 现代IM架构研 ...

  6. NOIP 模拟 $11\; \rm english$

    题解 本题有一定代码难度 对于需要区间最大值,可以反过来考虑,先预处理出每个数所能扩展的最大边界,也就是说,求出一个最大的区间,其最大值为这个数,单调栈 \(\mathcal O(n)\) 求解 那么 ...

  7. SpringBoot整合ActiveMq实现Queue和Topic两种模式(看不懂你来打我)

    目录 一.前言 二.ActiveMq的下载和使用 三.依赖准备 四.yml文件配置 五.配置Bean 六.创建生产者(Queue+Topic) 七.创建消费者(Topic模式下) 八.测试结果(Top ...

  8. 关于 go-fastdfs-web 的SpringBoot 后台管理

    1.问题的产生: 1.公司需要存储图片数据,采用Go语言的fastdfs,实现存储,我的职责就是部署,SpringBoot版本的管理平台. 2.当我看见代码之后我的内心是拒绝的,没有注释....... ...

  9. 解决maven中静态资源只能放到properties中的问题

    构建Maven项目的时候,如果没有进行特殊的配置,Maven会按照标准的目录结构查找和处理各种类型文件. Maven项目的标准目录结构 src main java         源文件 resour ...

  10. java发送短信开发,第三方接口方法

    必备的三个jar包Maven有自己去下: commons-logging commons-logging 1.1 commons-httpclient commons-httpclient 3.1 c ...