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



听说long long可以过就愉快地写了一个水bfs
从头搜索每一位
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <queue>
using namespace std;
const int N=1e6,INF=1e9;
typedef long long ll;
ll n;
queue<ll>q;
ll bfs(){
ll x;
while(!q.empty()) q.pop();
q.push();
while(!q.empty()){
x=q.front();
q.pop();
if(x%n==) return x;
q.push(x*);
q.push(x*+);
}
}
int main(){
while(~scanf("%lld",&n)){
if(n==) break;
printf("%lld\n",bfs());
}
return ;
}

POJ1426Find The Multiple[BFS]的更多相关文章

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

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

  2. ZOJ 1136 Multiple (BFS)

    Multiple Time Limit: 10 Seconds      Memory Limit: 32768 KB a program that, given a natural number N ...

  3. POJ 1465 Multiple (BFS,同余定理)

    id=1465">http://poj.org/problem?id=1465 Multiple Time Limit: 1000MS   Memory Limit: 32768K T ...

  4. poj 1426 Find The Multiple (bfs 搜索)

    Find The Multiple Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 18012   Accepted: 729 ...

  5. POJ1426-Find The Multiple(搜索)

    Find The Multiple Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 42035   Accepted: 176 ...

  6. TOJ3031: Multiple bfs

    3031: Multiple Time Limit(Common/Java):2000MS/6000MS     Memory Limit:65536KByte Total Submit: 60   ...

  7. POJ1426 Find The Multiple —— BFS

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

  8. poj1426--Find The Multiple(广搜,智商题)

    Find The Multiple Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 18527   Accepted: 749 ...

  9. POJ1426Find The Multiple

    http://poj.org/problem?id=1426 题意 : 输入一个数n,找n的倍数m,这个m所满足的条件是,每一位数只能由0或1组成,在题目的旁边用红色的注明了Special Judge ...

随机推荐

  1. HTML5 Maker – 在线轻松制作 HTML5 动画效果

    HTML5 Maker 是一个在线动画制作工具,帮助你使用 HTML,CSS 和 JavaScript 创建动态,互动的内容.它非常容易使用,同时可以帮你实现非常好的效果.它可以制作跨浏览器的动画内容 ...

  2. word-wrap、white-space和word break的区别

  3. 强大的<canvas>

    <canvas> 个人认为<canvas>是h5最重量级的新标签了,现在各种h5小游戏都是基于<canvas>的,它为游戏提供了一个功能强大的画布,可在画布上绘制丰 ...

  4. JavaScript基础20——element对象

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...

  5. 关于mapcontrol和pagelayoutcontrol切换时闪退

    今天遇到一个很奇怪的的现象,在tabcontrol里切换到pagelayout时,程序会闪退,试了下之前的程序,没有问题,去网上搜了一下,也没人有这样的问题,然后就开始实验,添加一个控件,运行一次,最 ...

  6. Projects\Portal_Content\Indexer\CiFiles文件夹下文件占用磁盘空间过大问题。

    C:\Program Files\Microsoft Office Servers\12.0\Data\Office Server\Applications\9765757d-15ee-432c-94 ...

  7. Sharepoint学习笔记—习题系列--70-576习题解析 -(Q66-Q68)

    Question 66 You are designing an application that will use a timer job that will run each night to s ...

  8. [Android]AndroidBucket增加碎片SubLayout功能及AISubLayout的注解支持

    以下内容为原创,转载请注明: 来自天天博客:http://www.cnblogs.com/tiantianbyconan/p/3709957.html 之前写过一篇博客,是使用Fragment来实现T ...

  9. Android通过PHP服务器实现登录

    Android客户端和PHP.MySQL搭建的服务器之间的简单交互,实现登录功能 . 实现原理图: Handler消息机制原理: Handler机制主要包括4个关键对象,分别是Message.Hand ...

  10. Android-SQLite版本问题

    1. 用户 重来没有使用过该软件 不存在数据库,我们 1). 自动调用 void onCreate(SQLiteDatabase db) 方法 创建数据库 2).创建 表 , 3).给表插入初始化数据 ...