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 题意:找到只由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的更多相关文章

  1. POJ1426 Find The Multiple —— BFS

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

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

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

  3. POJ1426——Find The Multiple

    POJ1426--Find The Multiple Description Given a positive integer n, write a program to find out a non ...

  4. POJ 1426 Find The Multiple --- BFS || DFS

    POJ 1426 Find The Multiple 题意:给定一个整数n,求n的一个倍数,要求这个倍数只含0和1 参考博客:点我 解法一:普通的BFS(用G++能过但C++会超时) 从小到大搜索直至 ...

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

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

  6. POJ1426Find The Multiple[BFS]

    Find The Multiple Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 27433   Accepted: 114 ...

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

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

  8. ZOJ 1136 Multiple (BFS)

    Multiple Time Limit: 10 Seconds      Memory Limit: 32768 KB a program that, given a natural number N ...

  9. poj1426 Find The Multiple

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

  10. POJ 1465 Multiple (BFS,同余定理)

    id=1465">http://poj.org/problem?id=1465 Multiple Time Limit: 1000MS   Memory Limit: 32768K T ...

随机推荐

  1. PHP开发环境搭建及开发工具

    PHP服务器组件非常多有WampServer.XAMPP.AppServ.phpStudy.phpnow等. 菜鸟教程推荐: WampServer,这也是目前window平台上使用最广泛的,操作也非常 ...

  2. java Semaphore信号灯

    Semaphore实现的功能就类似2个公用电话,假如有10个人要打电话:那么只能2个人占有电话,8个需要等待.当2个人中 的任何一个人让开后,其中等待的另外8个人中又有一个人可以使用了等待的8个人中可 ...

  3. [BZOJ3307] 雨天的尾巴(树上差分+线段树合并)

    [BZOJ3307] 雨天的尾巴(树上差分+线段树合并) 题面 给出一棵N个点的树,M次操作在链上加上某一种类别的物品,完成所有操作后,要求询问每个点上最多物品的类型. N, M≤100000 分析 ...

  4. Django中content-type组件

    django-content 1.需求 一家餐馆,有多个菜系,粤菜.湘菜.闽南菜.东北菜等,每个菜系中的菜品又分为小份.中份.大份,每个菜系对应的菜品量价格不同,现需要将该需求建表. 2. 建表方式 ...

  5. YARN的伪分布式安装

    前提:安装完HDFS以后 1.修改mapred-site.xml 这个文件初始时是没有的,有的是模板文件,mapred-site.xml.template 所以需要拷贝一份,并重命名为mapred-s ...

  6. 利用delegate来解决类之间相互引用问题(引用死锁)

    类之间相互引用--类A中需要调用类B中的方法,同时,类B中又要调用类A中的方法.(也被称为引用死锁,通常会出现编译错误). 解决方法是,在类A中引用类B,并使类A成为类B的delegate,这样在类A ...

  7. FTP客户端遇到150连接超时错误的处理办法

    环境:阿里云ECS,win server 2012 R2 / FTP Server(FileZilla 0.9.41) 问题描述:账号连接正常,但无法列出目录,提示150连接超时. 解决过程: 1.关 ...

  8. docker运行模式图

    docker运行模式图:

  9. day02 循环、格式化输出、运算符、编码

    01 昨日内容回顾 python2x python3x区别: python2x:源码重复,不规范. python3x:源码规范,优美,清晰,简单. 编译型:将代码一次性全部转化成字节码. 代表语言:C ...

  10. Docker的使用(未完待续)

    一.帮助命令 docker version docker info docker --help 二.镜像命令 列出机器上所有的镜像 docker images 查找某个镜像 docker search ...