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. js 柯里化、深拷贝、浅拷贝

    curry const sum = (a, b, c, d) => a + b + c + d const curry = fn => (judge = (...args) => a ...

  2. JVM(12)之 可视化分析工具

    开发十年,就只剩下这套架构体系了! >>>   经过前几篇博文对堆内存以及垃圾收集机制的学习,相信小伙伴们已经建立了一套比较完整的理论体系!本篇博客就根据已有的理论知识,通过可视化工 ...

  3. 【学习总结】Python-3-字符串函数-strip()方法

    参考: 菜鸟教程-Python3-Python字符串-strip()方法 语法: str.strip([chars]); 参数: chars -- 移除字符串头尾指定的字符序列. 返回值: 返回移除字 ...

  4. XMPP即时通讯协议使用(三)——订阅发布、断开重连与Ping

    package com.testV3; import java.util.List; import org.jivesoftware.smack.ConnectionListener; import ...

  5. django ORM数据库操作

    5.使用Django的ORM详细步骤: 1. 自己动手创建数据库 create database 数据库名; 2. 在Django项目中设置连接数据库的相关配置(告诉Django连接哪一个数据库) # ...

  6. Android kotlin静态属性、静态方法

    只需要用 companion object 包裹相应代码块即可.以静态属性为例: class Constants { companion object { val BASE_URL = "h ...

  7. PyQt5界面上调用subprocess.Popen会闪命令窗口的问题

    最近再做一个界面开发,主要实现的点击一个按钮,会执行adb安装应用程序的功能,在调试阶段一切都正常,但打包成一个exe安装程序,安装之后运行,点击按钮会闪一下adb的命令窗口 先列出subproces ...

  8. bzoj2004 [Hnoi2010]Bus 公交线路 矩阵快速幂+状压DP

    题目传送门 https://lydsy.com/JudgeOnline/problem.php?id=2004 题解 如果 \(N\) 没有那么大,考虑把每一位分配给每一辆车. 假设已经分配到了第 \ ...

  9. Spring----组合注解与元注解

    1.概述 1.1.Spring提供了大量的注解, 尤其是相同的注解用到各个类中,会相当的啰嗦: 1.2.元注解: 可以注解到别的注解上的注解: 组合注解: 被注解注解的注解称为 组合注解: 组合注解  ...

  10. Python"sorted()"和".sort()"的区别

    sorted(A-LIST)会返回一个新的object,不改变**A-LIST*本身. A-LIST.sort()会直接改变A-List,不产生新的object.