博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
poj1426——Find The Multiple(BFS)
阅读量:2344 次
发布时间:2019-05-10

本文共 1118 字,大约阅读时间需要 3 分钟。

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

把所有只含1和0的数枚举出来取余就行,然后用G++交才能过。。。

#include 
#include
#include
#include
#include
#include
#include
#define INF 0x3f3f3f3f#define MAXN 1010using namespace std;void bfs(int n){ queue
q; q.push(1); while(!q.empty()) { long long tmp=q.front(); q.pop(); if(tmp%n==0) { cout<
<
>n&&n) { bfs(n); } return 0;}

转载地址:http://bicvb.baihongyu.com/

你可能感兴趣的文章
CPU、GPU、CUDA,CuDNN 简介
查看>>
U-boot如何引导Linux内核启动?
查看>>
程序各个段text,data,bss,stack,heap
查看>>
如何利用ROS MoveIt快速搭建机器人运动规划平台?
查看>>
catkin_make &amp;amp;catkin build
查看>>
Camera和IMU的标定过程之kalibr 源码编译
查看>>
在ubuntu下安装python的numpy和scipy模块
查看>>
Ubuntu下apt-get与pip安装命令的区别
查看>>
linux CMakeLists.txt 语法
查看>>
cmake 简介
查看>>
CMake学习笔记(1)——用CMake编译一个hello world程序
查看>>
cmake使用总结---工程主目录CMakeList文件编写
查看>>
CMake学习之路
查看>>
cmake学习笔记6-catkin的CmakeList.txt讲解
查看>>
cmake手册详解
查看>>
Maplab框架介绍(一)
查看>>
Maplab开源VI-SLAM框架介绍
查看>>
maplab(1):安装
查看>>
陀螺仪随机误差的Allan方差分析
查看>>
Ubuntu 64位安装Adobe Reader 9.5.5
查看>>