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 题意很明确;输入一个数,输出这个数的哟个整倍数,输出的数必须只有0和1组成;我会告诉你这题Special Judge??
题目不是很难,用 long long +bfs(其实无所谓用不用)266ms 水过;
 #include<queue>
#include<cstdio>
using namespace std;
int N;
void bfs()
{
long long i,q,p=;
queue<long long>que;
que.push(p);
while(!que.empty())//简单BFS
{
p=que.front();
que.pop();
for(i=;i<;i++)//因为只有 0和1
{
q=*p+i;
if(q%N==)
{
printf("%lld\n",q);
return ;
}
que.push(q);
}
}
}
int main()
{
int a,b;
while(scanf("%d",&a)&&a)
{
if(a==)//1有点特殊,所以单独处理;
{
printf("1\n");
continue;
}
N=a;
bfs();
}
return ;
}

Find The Multiple(poj 1426)的更多相关文章

  1. BFS 或 同余模定理(poj 1426)

    题目:Find The Multiple 题意:求给出的数的倍数,该倍数是只由 1与 0构成的10进制数. 思路:nonzero multiple  非零倍数  啊. 英语弱到爆炸,理解不了题意... ...

  2. POJ 1426 Find The Multiple(寻找倍数)

    POJ 1426 Find The Multiple(寻找倍数) Time Limit: 1000MS    Memory Limit: 65536K Description - 题目描述 Given ...

  3. POJ - 1426 Find The Multiple(搜索+数论)

    转载自:優YoU  http://user.qzone.qq.com/289065406/blog/1303946967 以下内容属于以上这位dalao http://poj.org/problem? ...

  4. 01背包问题:Charm Bracelet (POJ 3624)(外加一个常数的优化)

    Charm Bracelet    POJ 3624 就是一道典型的01背包问题: #include<iostream> #include<stdio.h> #include& ...

  5. Scout YYF I(POJ 3744)

    Scout YYF I Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 5565   Accepted: 1553 Descr ...

  6. 广大暑假训练1(poj 2488) A Knight's Journey 解题报告

    题目链接:http://vjudge.net/contest/view.action?cid=51369#problem/A   (A - Children of the Candy Corn) ht ...

  7. Games:取石子游戏(POJ 1067)

    取石子游戏 Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 37662   Accepted: 12594 Descripti ...

  8. 并查集+关系的传递(poj 1182)

    题目:食物链 题意:给定一些关系.判断关系的正确性,后给出的关系服从之前的关系: 思路:难点不在并查集,在于关系的判断,尤其是子节点与根节点的关系的判断: 这个关系看似没给出,但是给出子节点与父节点的 ...

  9. 昂贵的聘礼(poj 1062)

    Description 年轻的探险家来到了一个印第安部落里.在那里他和酋长的女儿相爱了,于是便向酋长去求亲.酋长要他用10000个金币作为聘礼才答应把女儿嫁给他.探险家拿不出这么多金币,便请求酋长降低 ...

随机推荐

  1. git pull 部署问题一揽子问题解决

    之前遇到问题 在服务器拉取一直不成功, php 的shell函数 调用 git pull 一直不成功 ,但是单独 用root 权限 在机器上面 执行 git pull 是可以的 说明语法没问题. 而 ...

  2. 关于TXT转CHM的完整解决方式

    为什么要转CHM? 有些书,TXT的资源非常好找,而CHM的资源非常难找(先不论PDF格式的,只是话说PDF格式的没有一个书签文件夹看起来也非常难受) 而CHM格式在左側有一个文件夹结构,我最喜欢这个 ...

  3. iscsi介绍及iscsi target配置

    iSCSI 主要是透过 TCP/IP 的技术,将储存设备端透过 iSCSI target (iSCSI 目标) 功能,做成可以提供磁盘的服务器端,再透过 iSCSI initiator (iSCSI ...

  4. MapReduce输出格式

    针对前面介绍的输入格式,MapReduce也有相应的输出格式.默认情况下只有一个 Reduce,输出只有一个文件,默认文件名为 part-r-00000,输出文件的个数与 Reduce 的个数一致. ...

  5. Android read-only file system解决方法

    adb shell su - mount -o rw,remount /system

  6. VTMagic 的使用介绍

    VTMagic 有很多开发者曾尝试模仿写出类似网易.腾讯等应用的菜单分页组件,但遍观其设计,大多都比较粗糙,不利于后续维护和扩展.琢磨良久,最终决定开源这个耗时近两年打磨而成的框架,以便大家可以快速实 ...

  7. oracle的安装与plsql的环境配置

    1,首先得有oracle的安装包和plsql的安装包,安装包地址可见百度云 http://pan.baidu.com/s/1miTqhmg 2.解压下来进入0817账套,找到set.exe文件,双击安 ...

  8. Mysql表复制及备份还原

    1.复制表结构   1.1 含有主键等信息的完整表结构   CREATE table 新表名 LIKE book;     1.2 只有表结构,没有主键等信息   create table 新表名 s ...

  9. 在DataTable中更新、删除数据

    /*在DataTable中选择记录*/            /* 向DataTable中插入记录如上,更新和删除如下:             * ----但是在更新和删除前,首先要找出要更新和删除 ...

  10. Echarts使用随笔(2)-Echarts中mapType and data

    本文出处:http://blog.csdn.net/chenxiaodan_danny/article/details/39081071  series : [                {   ...