POJ1426 Find The Multiple (宽搜思想)

时间:2021-10-28 23:47:20
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&lpar;CF的某道&rpar; &amp&semi; 鬼畜宽搜

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

  5. BZOJ&lowbar;1615&lowbar;&lbrack;Usaco2008&lowbar;Mar&rsqb;&lowbar;The Loathesome&lowbar;Hay Baler&lowbar;麻烦的干草打包机&lowbar;&lpar;模拟&plus;宽搜&sol;深搜&rpar;

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

  6. 【宽搜】ECNA 2015 D Rings &lpar;Codeforces GYM 100825&rpar;

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

  7. 【宽搜】ECNA 2015 E Squawk Virus &lpar;Codeforces GYM 100825&rpar;

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

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

    题目链接: 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. python操作mysql数据库的相关操作实例

    python操作mysql数据库的相关操作实例 # -*- coding: utf-8 -*- #python operate mysql database import MySQLdb #数据库名称 ...

  2. nova分析(8)—— nova-compute

    nova-compute是管理和配置虚拟机的入口,在所有compute机器上都需要该服务来创建和管理虚拟机. nova-compute服务的入口在 nova.cmd.compute:main ,其启动 ...

  3. Scala刮:使用Intellij IDEA写hello world

    介绍 在前面的文章中,,我们介绍了如何使用Scala IDE那是,eclipse集成Scala开发插件Scala开发语言程序.使用一段时间后,.发现eclipse正确Scala支持不是很好.用户体验差 ...

  4. PHP获取当前类名、函数名、方法名

    PHP获取当前类名.方法名  __CLASS__ 获取当前类名  __FUNCTION__ 当前函数名(confirm)  __METHOD__ 当前方法名 (bankcard::confirm) _ ...

  5. JavaScript深入&lpar;操作BOM对象&rpar;

    浏览器对象模型(BOM) BOM的核心是window, 向下有: document(文档):document下由button,text,from,等等表单元素组成. location(地址对象),hi ...

  6. cf- Educational Codeforces Round 40 -D

    题意:给你n个点,m条边,一个起点s,一个终点t的无向图,问在某两个点之间加一条边,不改变s到t的最短路径的值的加法有多少种,所有点一定连接: 思路:首先,默认相邻两点的权值都为1,会改变值的情况有: ...

  7. GetComputerNameEx&lpar;&rpar;

    昨晚看了MSDN提供的GetComputerNameEx function(参考:https://msdn.microsoft.com/en-us/library/windows/desktop/ms ...

  8. Sona

    Sona Sona , Maven of the Strings . Of cause, she can play the zither. Sona can't speak but she can m ...

  9. 转载如何实现portlet之间的传递参数

    Liferay 6开发学习(三十):跨页面Portlet之间的调用与数据传递 2014年10月09日 Liferay 评论 2 条 阅读 4,209 views 次 Portlet之间的通信方法有多种 ...

  10. 第四篇:使用 CUBLAS 库给矩阵运算提速

    前言 编写 CUDA 程序真心不是个简单的事儿,调试也不方便,很费时.那么有没有一些现成的 CUDA 库来调用呢? 答案是有的,如 CUBLAS 就是 CUDA 专门用来解决线性代数运算的库. 本文将 ...