博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[kuangbin带你飞]专题一 简单搜索 E. Find The Multiple
阅读量:4557 次
发布时间:2019-06-08

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

Find The Multiple

题目链接:

题目:

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
26190
Sample Output
10100100100100100100111111111111111111 题意:给出一个整数n,(1 <= n <= 200)。求出任意一个它的倍数m,要求十进制m必须只由十进制的'0'或'1'组成。 思路:bfs,,将1压入队列中,进行1*10,1*10+1;就变成1->10,11,将10,11再压入队列中,进行操作,10->100,101,11->110,111.....
//// Created by hjy on 2019/7/10.//#include
#include
#include
#include
using namespace std;typedef long long ll;int m;void bfs(ll x){ queue
qu; qu.push(x); while(!qu.empty()) { ll result=qu.front(); qu.pop(); if(result%m==0) { cout<
<
>m&&m) { bfs(1); } return 0;}

 

转载于:https://www.cnblogs.com/Vampire6/p/11163092.html

你可能感兴趣的文章
linux中启动 java -jar 后台运行程序
查看>>
运行web项目端口占用问题
查看>>
Java Spring-IOC和DI
查看>>
【NOIP1999】【Luogu1015】回文数(高精度,模拟)
查看>>
Linux上安装Python3.5
查看>>
crt安装
查看>>
git切换分支报错:error: pathspec 'origin/XXX' did not match any file(s) known to git
查看>>
c++中static的用法详解
查看>>
转 我修改的注册表,但是程序运行起来,还是记着以前的
查看>>
图片轮播功能
查看>>
第六周小组作业:软件测试和评估
查看>>
linux Cacti监控服务器搭建
查看>>
debian(kali Linux) 安装net Core
查看>>
centos 7防火墙设置
查看>>
自定义进度条(圆形、横向进度条)
查看>>
spark-streaming-kafka采坑
查看>>
9.Mongodb与python交互
查看>>
18-[JavaScript]-函数,Object对象,定时器,正则表达式
查看>>
读取短信回执
查看>>
EF 数据初始化
查看>>