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. 【web前端面试题整理06】成都第一弹,邂逅聚美优品

    前言 上周四回了成都,休息了一下下,工作问题还是需要解决的,于是今天去面试了一下,现在面试回来了,我感觉还是可以整理一下心得. 这个面试题整理系列是为了以后前端方面的兄弟面试时候可以得到一点点帮助,因 ...

  2. [读码]HTML5像素文字爆炸重组

    [边读码,边学习,技术也好,思路也罢] [一款基于HTML5技术的文字像素爆炸重组动画特效,我们可以在输入框中指定任意文字,点击确定按钮后,就会将原先的文字爆炸散去,新的文字以像素点的形式组合起来,看 ...

  3. mongodb 查询的用法

    想要在C#中使用MongoDB,首先得要有个MongoDB支持的C#版的驱动.C#版的驱动貌似有很多种,如官方提供的samus. 实现思路大都类似.这里我们用官方提供的mongo-csharp-dri ...

  4. sass高级语法

    github地址:https://github.com/lily1010/sass/tree/master/course03 用到的sass语法是: sass --watch test.scss:te ...

  5. jquery对象和DOM对象的互相转换

    实际开发中,jq用的很多,jq对象不能调用原生js操作方法,DOM对象当然也不能调用jq的方法,有时候我们可以用到jq对象和jsDOM对象的相互转换. 在jq中,只需要调用[index]和get(in ...

  6. 微软正开发Office Reader和Office Lens

    据熟知微软Office计划的消息人士透露,微软目前正开发新Windows 8风格的Office应用程序,该应用程序代号被微软称为Office Reader,而为Windows Phone开发的应用程序 ...

  7. [Android]实现类似微信的延迟加载的Fragment——LazyFragment

    以下内容为原创,转载请注明: 来自天天博客:http://www.cnblogs.com/tiantianbyconan/p/4303910.html  参考微信,使用ViewPager来显示不同的t ...

  8. Android 使用SoundPool播放音效

    在Android开发中我们经常使用MediaPlayer来播放音频文件,但是MediaPlayer存在一些不足,例如:资源占用量较高.延迟时间较长.不支持多个音频同时播放等.这些缺点决定了MediaP ...

  9. Android AsyncTask 源码解析

    1. 官方介绍 public abstract class AsyncTask extends Object  java.lang.Object    ↳ android.os.AsyncTask&l ...

  10. 【代码笔记】iOS-点击一个button,出6个button

    一,效果图. 二,工程图. 三,代码. RootViewController.h #import <UIKit/UIKit.h> //加入头文件 #import "DCPathB ...