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 给你一个n,让你找一个n的倍数,它的每个位不是0就是1。
这次题解用咆哮体写题解!这题是搜索你敢信?这题答案不超过unsigned __int64 你敢信?啊? 啊! 啊?
网络上还有说什么考到同余定理的人?你不知道答案不超unsigned __int64,你敢写?
代码如下:
 #include<iostream>
#include<cstdlib>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
using namespace std;
bool found;
int n;
void dfs(unsigned __int64 x,int step)
{
if(found)
return ;
if(x%n==)
{
printf("%I64u\n",x);
found=true;
return ;
}
if(k==)
return ;
dfs(x*,step+);
dfs(x*+,step+);
}
int main()
{
while(cin>>n,n)
{
found=false;
dfs(,);
}
return ;
}

最后提醒下自己写prinf 是老老实实写%I64u...

 

POJ 1426 Find The Multiple (dfs??!!)的更多相关文章

  1. POJ 1426 Find The Multiple (DFS / BFS)

    题目链接:id=1426">Find The Multiple 解析:直接从前往后搜.设当前数为k用long long保存,则下一个数不是k*10就是k*10+1 AC代码: /* D ...

  2. POJ 1426 Find The Multiple(数论——中国同余定理)

    题目链接: http://poj.org/problem?id=1426 Description Given a positive integer n, write a program to find ...

  3. POJ 1426 Find The Multiple(寻找倍数)

    POJ 1426 Find The Multiple(寻找倍数) Time Limit: 1000MS    Memory Limit: 65536K Description - 题目描述 Given ...

  4. POJ.1426 Find The Multiple (BFS)

    POJ.1426 Find The Multiple (BFS) 题意分析 给出一个数字n,求出一个由01组成的十进制数,并且是n的倍数. 思路就是从1开始,枚举下一位,因为下一位只能是0或1,故这个 ...

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

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

  6. POJ - 1426 Find The Multiple(搜索+数论)

    转载自:優YoU  http://user.qzone.qq.com/289065406/blog/1303946967 以下内容属于以上这位dalao http://poj.org/problem? ...

  7. poj 1426 Find The Multiple (简单搜索dfs)

    题目: Given a positive integer n, write a program to find out a nonzero multiple m of n whose decimal ...

  8. 题解报告:poj 1426 Find The Multiple(bfs、dfs)

    Description Given a positive integer n, write a program to find out a nonzero multiple m of n whose ...

  9. poj 1426 Find The Multiple( bfs )

    题目:http://poj.org/problem?id=1426 题意:输入一个数,输出这个数的整数 倍,且只有0和1组成 程序里写错了一个数,结果一直MLE.…… #include <ios ...

随机推荐

  1. python学习笔记(二)列表操作

    列表及列表操作: 列表是最常用的数据类型之一,列表也叫数组,列表定义,使用[]即可:列表里面可以再套列表,一个里面套一个列表,叫二维数组:一个里面套一个列表,里面的列表再套一个列表,这个叫三位数组,套 ...

  2. Delphi 如何在程序中执行动态生成的Delphi代码

    如何在程序中执行动态生成的Delphi代码 经常发现有人提这类问题,或者提问内容最后归结成这种问题 前些阵子有位高手写了一个“执行动态生成的代码”,这是真正的高手,我没那种功力,我只会投机取巧. 这里 ...

  3. EAM(Enterprise Asset Management)企业资产管理系统

    EAM (Enterprise Asset Management)的缩写,EAM系统是指企业资产管理系统. EAM系统是在资产比重较大的企业,在资产建设.维护中减少维护成本,提高资产运营效率,通过现代 ...

  4. LOJ 3092 「BJOI2019」排兵布阵 ——DP

    题目:https://loj.ac/problem/3092 同一个人的不同城堡之间没有什么联系,只是和<=m.所以对每个城堡的 s 个值排序,做一个 f[ i ][ j ] 表示第 i 个城堡 ...

  5. window安装nginx

    下载安装 到nginx官网上下载相应的安装包,http://nginx.org/en/download.html: 下载进行解压,将解压后的文件放到自己心仪的目录下,我的解压文件放在了d盘根目录下,如 ...

  6. LINUX 文件合并,去重

    (1)两个文件的交集,并集前提条件:每个文件中不得有重复行1. 取出两个文件的并集(重复的行只保留一份)cat file1 file2 | sort | uniq > file32. 取出两个文 ...

  7. sql查询某个时间内的数据

    hour) 七天之前的数据 SELECT * FROM commodity_order where create_time <= (now()-INTERVAL 7 DAY) order by ...

  8. <读书笔记>JavaScript系列之7种创建对象(面向对象)

    写在前面: 以下三选一: 阅读博文JavaScript 对象详解. 阅读<JavaScript权威指南>第6章. 阅读<JavaScript高级程序设计>第6章. 注意:只需要 ...

  9. 2019牛客国庆集训派对day1(A, B E F K)

    链接:https://ac.nowcoder.com/acm/contest/1099#question A:可知符合条件的图中间肯定存在一个由1构成的矩形,找到由1构成矩形的边界,判断出现的1的数量 ...

  10. spring data jpa 使用方法命名规则查询

    按照Spring Data JPA 定义的规则,查询方法以findBy开头,涉及条件查询时,条件的属性用条件关键字连接,要注意的是:条件属性首字母需大写.框架在进行方法名解析时,会先把方法名多余的前缀 ...