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. TensorFlow 安装报错的解决办法

    最近关注了几个python相关的公众号,没事随便翻翻,几天前发现了一个人工智能公开课,闲着没事,点击了报名. 几天都没有音信,我本以为像我这种大龄转行的不会被审核通过,没想到昨天来了审核通过的电话,通 ...

  2. centos7配置sudo免密

    1.chmod  +w   /etc/sudoers 2.vim  /etc/sudoers 在已经有了的root下面加 username  ALL=NOPASSWD:ALL      (这是所有的命 ...

  3. 【JAVA】 05-String类和JDK5

    链接: 笔记目录:毕向东Java基础视频教程-笔记 GitHub库:JavaBXD33 目录: <> <> 内容待整理: API-String 特点 String类: 1.St ...

  4. 分页插件 Bootstrap Paginator

    Bootstrap Paginator是一款基于Bootstrap的js分页插件,功能很丰富,个人觉得这款插件已经无可挑剔了.它提供了一系列的参数用来支持用户的定制,提供了公共的方法可随时获得插件状态 ...

  5. springboot全局字符编码设置

    1.在application.properties中设置 #编码格式 spring.http.encoding.force=true spring.http.encoding.charset=UTF- ...

  6. 谈一谈测试驱动开发(TDD)的好处以及你的理解

    DD是指在编写真正的功能实现代码之前先写测试代码,然后根据需要重构实现代码.在JUnit的作者Kent Beck的大作<测试驱动开发:实战与模式解析>(Test-Driven Develo ...

  7. jQuery-Ajax请求Json数据并加载在前端页面,附视频教程讲解!

    Ajax技术应用广泛,这种异步加载技术,无需刷新网页即可更新网站内容,全局或者局部均可,所以大家应该学会这种技巧,把技术用上来. 创建demo.json文件,用来做数据源: {     "t ...

  8. 单例设计模式(Singleton)的优化

    单例模式的优化 单例模式懒汉式写法,单例模式的优化有以下四个方面: 使用同步保证线程安全synchronized 使用volatile关键字:volatile关键字提醒编译器后面所定义的变量随时都有可 ...

  9. hive中的列转行和行转列

    1.列转行 1.1 相关函数的说明: concat(string1,string,...) //连接括号内字符串,数量不限. concat_ws(separator,string1,string2,. ...

  10. vue.js 导出JSON

    cnpm install file-saver --save <template> <div class="hello"> <button @clic ...