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. 文件名过滤器FilenameFilter的用法

    Java.io.FilenameFilter是文件名过滤器,用来过滤不符合规格的文件名,并返回合格的文件: 实例1,匹配指定字符结尾的文件 package cn.test; import java.i ...

  2. MQ java 基础编程(一)

    本文转自:http://www.blogjava.net/i369/articles/88035.html 编写人:邬文俊 编写时间 : 2006-2-16 联系邮件 : wenjunwu430@gm ...

  3. mybatis 之 parameterType="java.util.HashMap">

    /** * 根据goods_no 和 goods_id 来查询商品信息 * * @param goodsNos * @return */ public List<Goods> getGoo ...

  4. sqlite3错误码整理

    #define SQLITE_OK /* 成功 | Successful result */ /* 错误码开始 */ #define SQLITE_ERROR /* SQL错误 或 丢失数据库 | S ...

  5. 【LeetCode OJ】Add Two Numbers

    题目:You are given two linked lists representing two non-negative numbers. The digits are stored in re ...

  6. Barcode.js功能强大的条码生成jQuery插件

    本文转载自http://www.uedsc.com/barcode-js.html Barcode.js是一个基于jQuery库的插件,用于绘制条形码或者二维码,能够生成基于DIV+CSS或者Canv ...

  7. Linux设备驱动剖析之SPI(一)

    写在前面 初次接触SPI是因为几年前玩单片机的时候,由于普通的51单片机没有SPI控制器,所以只好用IO口去模拟.最近一次接触SPI是大三时参加的校内选拔赛,当时需要用2440去控制nrf24L01, ...

  8. 【大数据系列】在hadoop2.8.0下配置SecondaryNameNode

    修改namenode上的hdfs-site.xml configuration> <property> <name>dfs.replication</name> ...

  9. Python pyQt4/pyQt5 学习笔记2(状态栏、菜单栏和工具栏)

    例子:状态栏.菜单栏和工具栏 import sys from PyQt4 import QtGui class Example(QtGui.QMainWindow): def __init__(sel ...

  10. Elasticsearch学习之深入搜索五 --- phrase matching搜索技术

    1. 近似匹配 什么是近似匹配,两个句子 java is my favourite programming language, and I also think spark is a very goo ...