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 题意是求出n任意一个倍数而这个数是只有0和1构成的十进制整数,输出任意符合题意的答案即可;
我们可以输出最小的符合条件的;这个数第一位一定为1;接着判断10,11,101,100,110,111......;可以用bfs来写; 代码如下:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
using namespace std;
__int64 bfs(int n)
{
queue<__int64>Q;
Q.push();
long long q;
while(!Q.empty())
{
q=Q.front();
Q.pop();
if(q%n==)
return q;
Q.push(q*);
Q.push(q*+);
}
return -;
} int main()
{
int n;
__int64 ans;
while(scanf("%d",&n),n)
{
ans=bfs(n);
printf("%I64d\n",ans);
}
return ;
}

												

Find The Multiple--POJ1426的更多相关文章

  1. Find the Multiple POJ-1426

    题目链接:Find the Multiple 题目大意 找出一个只由0和1组成的能整除n的数. 思路 所有由0和1组成的数可以看作是某个只由0.1组成的数a经过以下两种变化得到 1.a * 10 2. ...

  2. POJ1426——Find The Multiple

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

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

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

  4. poj1426 Find The Multiple

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

  5. Find The Multiple (poj1426 一个好的做法)

    Find The Multiple Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 16505   Accepted: 673 ...

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

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

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

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

  8. POJ1426 Find The Multiple —— BFS

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

  9. 【POJ1426】Find The Multiple

    本题传送门 本题知识点:深度优先搜索 | 宽度优先搜索 题意很简单,让我们找一个只有1和0组成的十位数是n的倍数的数. 这题一开始吓到我了--因为Output里说输出的长度最长不超过100位???那是 ...

  10. poj1426 Find The Multiple (DFS)

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

随机推荐

  1. Google TensorFlow 机器学习框架介绍和使用

    TensorFlow是什么? TensorFlow是Google开源的第二代用于数字计算(numerical computation)的软件库.它是基于数据流图的处理框架,图中的节点表示数学运算(ma ...

  2. 《转》Python学习(19)-python函数(二)-关于lambda

    转自http://www.cnblogs.com/BeginMan/p/3178103.html 一.lambda函数 1.lambda函数基础: lambda函数也叫匿名函数,即,函数没有具体的名称 ...

  3. 《转》Python学习(13)-Python的字符编码

    转自 http://www.cnblogs.com/BeginMan/p/3166363.html 一.字符编码中ASCII.Unicode和UTF-8的区别 点击阅读:http://www.cnbl ...

  4. 基于WordNet的英文同义词、近义词相似度评估及代码实现

    源码地址:https://github.com/XBWer/WordSimilarity 1.确定要解决的问题及意义 在基于代码片段的分类过程中,由于程序员对数据变量名的选取可能具有一定的规范性,在某 ...

  5. css笔记 - 张鑫旭css课程笔记之 relative 篇

    relative地址 relative 对 absolute的限制作用 限制left/top/right/bottom(方位值)定位 限制描述:absolute设置了方位值时,这些方位值是相对于pos ...

  6. Building Boost for Android with error “cannot find -lrt”

    编辑tools/build/src/tools/gcc.jam rule setup-threading ( targets * : sources * : properties * ){ local ...

  7. MyBatis学习之输入输出类型

    1.  传递pojo对象 Mybatis使用ognl表达式解析对象字段的值,#{}或者${}括号中的值为pojo属性名称,其中,#{}:占位符号,好处防止sql注入,${}:sql拼接符号, 简要说明 ...

  8. 【JSP】JSP的介绍和基本原理

    JSP简介 JSP的核心实质是Servlet技术.JSP是后来添加的基于Servlet的一种扩展技术.但二者在使用上有不同的方向. 由于Servlet实质是一个Java类,因此非常适合用来处理业务逻辑 ...

  9. listctrl查找定位 使用测试过还很好用

    35.listctrl查找定位  使用测试过还很好用 // 简单的查找函数// FindString(CListCtrl& , 查找内容 , 开始位置 , 到达底部时是否从头查找) int F ...

  10. PCB 铺铜 转载

    所谓覆铜,就是将PCB上闲置的空间作为基准面,然后用固体铜填充,这些铜区又称为灌铜.敷铜的意义在于,减小地线阻抗,提高抗干扰能力:降低压降,提高电源效率:还有,与地线相连,减小环路面积.如果PCB的地 ...