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. 使用C#获取IP地址方法

    C#中如何获取IP地址?,看到问题的时候我也很纠结,纠结的不是这个问题是如何的难回答,而是纠结的是这些问题都是比较基本的常识,也是大家会经常用到的.但是却不断的有人问起,追根究底的原因估计就是没有好好 ...

  2. [CF1161F]Zigzag Game

    通过这道模板题学了一种新的模型,记录一下. 稳定婚姻匹配 至于这道题,显然是一个二分图博弈的模型.考虑选择Bob,我们要找一组匹配使得任何情况下Bob都有匹配边能走.不失一般性假设Alice选择了in ...

  3. 树结构遍历节点名字提取,这里提取的是el-tree数据结构,封装成函数

    /** * 树形数据提取节点 * @param {*} data */ export function treeDataGetnode (data) { var res = [] var child= ...

  4. BZOJ 3687: 简单题(dp+bitset)

    传送门 解题思路 设\(f(i)\)表示和为\(i\)时的方案数,那么转移方程为\(f(i)+=f(i-x)\),\(x\)为当前枚举到的数字,这样做是\(O(n\sum a_i)\)的,考虑优化.发 ...

  5. 6105 - deauth after EAPOL key exchange sequence

    wifi无法连接公司的网络 Warning Error in Event Log - deauth after EAPOL key exchange sequence https://forums.i ...

  6. AST7D08 心率计

    接线: 1.GND 2.+3.3V 3.RST 4. 5.CS 6.READY 7.DI 8.DO 9.CLK

  7. 104、Tensorflow 的变量重用

    import tensorflow as tf # 在不同的变量域中调用conv_relu,并且声明我们想创建新的变量 def my_image_filter(input_images): with ...

  8. Problem accessing /jenkins/. Reason:

    这是一个Jenkins的Bug.临时解决方法是:在浏览器中手工输入:http://<ip>:<port>.不要访问"/jenkins"这个路径.

  9. Java反射实现Servlet处理多个请求--server分发

    import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.serv ...

  10. 《单词的减法》state1~state17(第一遍学习记录)

    单词的减法 2016.05.18 state 1 accordingly 因此,相应地,对应地 advisory 顾问的,劝告的 annoy 打扰,干扰,使恼怒 anticipate/particip ...