Find The Multiple
Time Limit: 1000MS   Memory Limit: 10000K
Total Submissions: 24768   Accepted: 10201   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

Source

题意:求n个一个倍数,但这个数必须是01串

其实就是利用宽搜的思想枚举: 第一个数是1 , 然后下一个就是 10 (1 * 10) , 11( 1 * 10 + 1),再下一个就是 100(10 * 10), 101(10 * 10 + 1),110 (11 * 10),111(11 * 10 + 1) ...然后比较坑的就是只要是n个一个倍数就行,结果不用跟这个样例一样也可以,然后用long long也能过=_=

 #include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
using namespace std;
typedef long long LL;
void bfs(int n)
{
queue<LL> q;
q.push();
while (!q.empty())
{
LL temp = q.front();
q.pop();
if (temp % n == )
{
printf("%lld\n", temp);
return;
}
q.push(temp * );
q.push(temp * + );
}
}
int main()
{
int n;
while (scanf("%d", &n) != EOF && n)
{
bfs(n);
}
return ;
}

POJ1426 Find The Multiple (宽搜思想)的更多相关文章

  1. poj1426 Find The Multiple

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

  2. poj1399 hoj1037 Direct Visibility 题解 (宽搜)

    http://poj.org/problem?id=1399 http://acm.hit.edu.cn/hoj/problem/view?id=1037 题意: 在一个最多200*200的minec ...

  3. 利用深搜和宽搜两种算法解决TreeView控件加载文件的问题。

    利用TreeView控件加载文件,必须遍历处所有的文件和文件夹. 深搜算法用到了递归. using System; using System.Collections.Generic; using Sy ...

  4. Colorado Potato Beetle(CF的某道) & 鬼畜宽搜

    题意: 一个人在一张大图上走,给你路径与起点,求他走出的矩形面积并.(大概这个意思自行百度标题... SOL: 与其说这是一道图论题不如说是一道生动活泼的STL-vector教学.... 离散化宽搜, ...

  5. BZOJ_1615_[Usaco2008_Mar]_The Loathesome_Hay Baler_麻烦的干草打包机_(模拟+宽搜/深搜)

    描述 http://www.lydsy.com/JudgeOnline/problem.php?id=1615 一个主动轮带着一些轮子转,轮子带着轮子转,轮子带着轮子转...一个非主动轮只会被一个轮子 ...

  6. 【宽搜】ECNA 2015 D Rings (Codeforces GYM 100825)

    题目链接: http://codeforces.com/gym/100825 题目大意: 给你一张N*N(N<=100)的图表示一个树桩,'T'为年轮,'.'为空,求每个'T'属于哪一圈年轮,空 ...

  7. 【宽搜】ECNA 2015 E Squawk Virus (Codeforces GYM 100825)

    题目链接: http://codeforces.com/gym/100825 题目大意: N个点M条无向边,(N<=100,M<=N(N-1)/2),起始感染源S,时间T(T<10) ...

  8. 【拓扑】【宽搜】CSU 1084 有向无环图 (2016湖南省第十二届大学生计算机程序设计竞赛)

    题目链接: http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1804 题目大意: 一个有向无环图(DAG),有N个点M条有向边(N,M<=105 ...

  9. 【图论】【宽搜】【染色】NCPC 2014 A Ades

    题目链接: http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1787 题目大意: N个点M条无向边(N,M<=200000),一个节点只能有一个 ...

随机推荐

  1. MVC架构设计——EF-Code First

    详情参考:http://www.cnblogs.com/guomingfeng/archive/2013/05/28/mvc-ef-repository.html

  2. BroadcastReceiver之有序广播

    有序广播可以按一定的优先级进行传播 首先进行发送广播 public void click(View v){ Intent intent = new Intent(); intent.setAction ...

  3. FlashFXP|FTP

    经典的FTP传输工具FlashFxp,留作几年吧!看和曾经用的软件代表着岁月的流逝和时间的推进性! 洒脱度过生活中的每一天.每一分钟,Mvpbang追随一生! 压缩包中有秘钥文件-flashfxp.k ...

  4. C# Label显示多行文本及换行(WinForm/WebForm)

    转载: http://www.cnblogs.com/greatverve/archive/2011/10/20/label-multi.html WinForm 很多朋友都会在开发WinForm中遇 ...

  5. Linux下解决用户不能执行sudo的方法

    报错: xxx is not in the sudoers file.  This incident will be reported. Linux默认没有为当前用户开启sudo权限! $ su  $ ...

  6. 大规模数据 从SQL SERVER导入到ORACLE方法

    来源于:http://blog.csdn.net/iitkd/article/details/40394789 来源:一个7G的SQL SERVER .bak文件要导入到Oracle中,经过实验,完成 ...

  7. selector 和 shape结合使用

    <?xml version="1.0" encoding="utf-8"?><selector xmlns:android="htt ...

  8. Qt做动画旋转旋转图片

    今天看到百度首页的音乐播放有个图片可以旋转,感觉很酷就用qt做了一个类似的,关键时刻还是要发挥数学功底,静下心来,写一写,画一画,编程对数学分析能力要求还是不小的,以后要经常锻炼数学分析能力啊! Wi ...

  9. jenkins 把包传到远程服务器上

    首先我们在 一台服务器上部署svn,maven,jdk,tomcat,nexus,还有Jenkins. 这里我主要记录Jenkins. 首先我们从网上下载Jenkins的包 wget http://m ...

  10. 在Windows .NET平台下使用Memcached

    网上关于Memcached的文章很多,但据我观察,大多是互相转载或者抄袭的,千篇一律.有些则是直接整理的一些超链接然后贴出来.那些超链接笔者大概都进去看了,其实关于Memcached的中文的技术文章, ...