POJ1426——Find The Multiple

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

代码:

#include<iostream>
#include<bits/stdc++.h>
#include<queue>
using namespace std; void BFS(int x){
queue<int> q ;
q.push(1);
int y;
while (!q.empty())
{
y=q.front();
q.pop();
for (int i = 0; i < 2; i++)
{
if (i==0) q.push(y*10);
else
q.push(y*10+1);
if (y%x==0)
{
cout<<y<<endl;
return ;
} }
}
} int main(){
int x;
while ((cin>>x)&&x)
{
BFS(x);
}
}

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

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

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

  2. poj1426 Find The Multiple

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

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

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

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

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

  5. POJ1426 Find The Multiple —— BFS

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

  6. poj1426 Find The Multiple (DFS)

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

  7. POJ1426 Find The Multiple 解题报告

    参考:http://www.cnblogs.com/ACShiryu/archive/2011/07/24/2115356.html #include <iostream> #includ ...

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

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

  9. POJ1426——Find The Multiple (简单搜索+取余)

    题意: 给一个数n,让你找出一个只有1,0,组成的十进制数,要求是找到的数可以被n整除. 用DFS是搜索 当前位数字 (除最高位固定为1),因为每一位都只有0或1两种选择,换而言之是一个双入口BFS. ...

随机推荐

  1. 【原创】在macOS Big Sur (Silicon M1, ARM)中配置ASP运行环境

    亲测有效,转载请附原文地址. 一,安装Parallels Desktop,注意选择支持ARM的版本. 二,注册 Windows Insider Preview Downloads 账号,通过以下链接下 ...

  2. 使用AVPro Video在Unity中播放开场视频(CG)笔记

    游戏中的开场CG(播放视频),采用的插件为AVPro Video1.x(和W的版本一致),Unity版本为2018.4.0f1 Asset Store:AVPro Video - Core Andro ...

  3. Java8新特性(三)之方法引用和构造器引用

    1.使用场景 当要传递给Lambda体的操作,已经存在实现的方法了,就可以使用方法引用.(抽象方法的参数列表  必须与方法引用方法的参数列表保持一致) 2. 语法 使用操作符[::]将方法名和对象或类 ...

  4. 在包一级定制log4j日志输出

    软件开发和维护过程中,日志是必不可少的工具,对于一个10万行规模的产品,要分析它的某一部分,最简单的方法是将log4j配置文件的rootLogger的输出级别设置为debug,但这样将使产品的所有部分 ...

  5. Awesome Notes

    Install $ sudo aptitude install awesome Build from source $ aria2c -s 5 http://awesome.naquadah.org/ ...

  6. git submodule 操作

    git submodule foreach git status 举一反三,对所有子库的操作,都可以使用 git submodule foreach 做前缀 foreach,可以记忆为for each ...

  7. <span> 标签与<p>标签的区别

    p标签指一个段落,是块级元素,有换行效果:span是行内元素,一般单独修饰文字: span 标签可以放在p标签里,p标签不应该放在span标签里:

  8. S3C2440—10.代码重定位

    文章目录 一.启动方式 1.1 NAND FLASH 启动 1.2 NOR FLASH 启动 二. 段的概念 2.1 重定位数据段 2.2 加载地址的引出 三.链接脚本 3.1 链接脚本的引入 3.2 ...

  9. noip40

    T1 记当前位置 \(i\) 上的颜色,上次出现的位置为 \(last_{1}\) ,上上次出现的位置为 \(last_{2}\) ,则,把当前点的颜色加进来,并且让其产生贡献的话,则会对 \([la ...

  10. 异步编程async体会

    namespace 异步编程{ class Program { static void Main(string[] args) { Console.WriteLine("mian this ...