POJ 1426   Find The Multiple
Time Limit: 1000MS   Memory Limit: 10000K
Total Submissions: 25734   Accepted: 10613   Special Judge

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,幸好题目的数据范围没有超过int*/
/*---------------------*/
#define N 200
#include<iostream>
using namespace std;
#include<cstdio>
#include<queue>
queue<long long>que;
int main()
{
freopen("1.out","w",stdout);
for(int i=;i<=N;++i)
{
que.push();
while(!que.empty())
{
long long x=que.front();
que.pop();
if(x%i==)
{
cout<<x<<",";
break;
}
que.push(x*);
que.push(x*+);
}
while(!que.empty()) que.pop();
}
return ;
}
/*-----------------------------------------------------------*/
#include<iostream>
using namespace std;
long long ans[]={,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,};
int main()
{
int n;
while(cin>>n)
{
if(n==) break;
cout<<ans[n]<<endl;
}
return ;
}

广搜+打表 POJ 1426 Find The Multiple的更多相关文章

  1. POJ 1426 Find The Multiple --- BFS || DFS

    POJ 1426 Find The Multiple 题意:给定一个整数n,求n的一个倍数,要求这个倍数只含0和1 参考博客:点我 解法一:普通的BFS(用G++能过但C++会超时) 从小到大搜索直至 ...

  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 (BFS)

    POJ.1426 Find The Multiple (BFS) 题意分析 给出一个数字n,求出一个由01组成的十进制数,并且是n的倍数. 思路就是从1开始,枚举下一位,因为下一位只能是0或1,故这个 ...

  4. DFS/BFS(同余模) POJ 1426 Find The Multiple

    题目传送门 /* 题意:找出一个0和1组成的数字能整除n DFS:200的范围内不会爆long long,DFS水过~ */ /************************************ ...

  5. [深度优先搜索] POJ 1426 Find The Multiple

    Find The Multiple Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 28550   Accepted: 118 ...

  6. POJ 1426 Find The Multiple BFS

    没什么好说的 从1开始进行广搜,因为只能包涵0和1,所以下一次需要搜索的值为next=now*10 和 next=now*10+1,每次判断一下就可以了,但是我一直不太明白我的代码为什么C++提交会错 ...

  7. POJ 1426 Find The Multiple (DFS / BFS)

    题目链接:id=1426">Find The Multiple 解析:直接从前往后搜.设当前数为k用long long保存,则下一个数不是k*10就是k*10+1 AC代码: /* D ...

  8. 广搜+输出路径 POJ 3414 Pots

    POJ 3414 Pots Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 13547   Accepted: 5718   ...

  9. 【PTA 天梯赛】L2-026. 小字辈(广搜+邻接表)

    本题给定一个庞大家族的家谱,要请你给出最小一辈的名单. 输入格式: 输入在第一行给出家族人口总数 N(不超过 100 000 的正整数) —— 简单起见,我们把家族成员从 1 到 N 编号.随后第二行 ...

随机推荐

  1. javascript 之拼接html字符串

    // var one = {"id":1, "leasetime":2, "ney":0,"myhuifangshi": ...

  2. 【iOS】通知监听

    下例为:监听文本框  accountField  内容的改变, 当发生改变时, 调用textChange方法(多次).监听结束需要移除通知. - (void)viewDidLoad { [super ...

  3. ASP.NET Core 1.0开发Web API程序

    .NET Core版本:1.0.0-rc2Visual Studio版本:Microsoft Visual Studio Community 2015 Update 2开发及运行平台:Windows ...

  4. 线上mysql内存持续增长直至内存溢出被killed分析(已解决)

    来新公司前,领导就说了,线上生产环境Mysql库经常会发生日间内存爆掉被killed的情况,结果来到这第一天,第一件事就是要根据线上服务器配置优化配置,同时必须找出现在mysql内存持续增加爆掉的原因 ...

  5. Linux编辑器vim键盘详解

    下面的这张图,一看就明白了,从此,学习变的不再艰难! 补注:图中没有关于查找和替换的,应该用下面的.自上而下的查找操作                  /word小写的n和N自下而上的查找操作    ...

  6. ASP.Net页面刷新后自动滚动到原来位置

    在网上搜索之后总结了三种方式: 1.设置Page中的MaintainScrollPositionOnPostback属性为true A>.页面里有MaintainScrollPositionOn ...

  7. 解决SharePoint 文档库itemadded eventhandler导致的上传完成后,编辑页面保持报错的问题,错误信息为“该文档已经被编辑过 the file has been modified by...”

    在文档库中添加itemadded 后,在上传文件后,会自动打开文档属性的编辑页面,在保存的时候就会报错,说这个文档已经被编辑过了.这是应为默认itemadded实践是异步执行的,会在edit页面打开之 ...

  8. 复制转移sharepoint 2010 designer做的list workflow的方法

    SharePoint 2010 designer做的workflow都有一个导出到visio的功能,但是如果是list workflow一般都是不可重用的,即使导出了,也是导不进目标站点或者list的 ...

  9. Sharepoint学习笔记—习题系列--70-573习题解析 -(Q127-Q130)

    Question 127You create a custom list named Products.You need to perform a Representational State Tra ...

  10. 斯坦福iOS7公开课1-3笔记及纸牌Demo

    1.MVC Model:模型 描述程序是什么,例如数据库操作之类的行文以及纸牌Demo里纸牌玩法都是写在Model这一层,通过Notification和KVO(后续文章会介绍)两种方式与Control ...