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

  1. 2
  2. 6
  3. 19
  4. 0

Sample Output

  1. 10
  2. 100100100100100100
  3. 111111111111111111
  4.  
  5. 给你一个n,让你找一个n的倍数,它的每个位不是0就是1
    这次题解用咆哮体写题解!这题是搜索你敢信?这题答案不超过unsigned __int64 你敢信?啊? 啊! 啊?
    网络上还有说什么考到同余定理的人?你不知道答案不超unsigned __int64,你敢写?
    代码如下:
  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<cstdio>
  4. #include<cstring>
  5. #include<algorithm>
  6. #include<cmath>
  7. #include<queue>
  8. using namespace std;
  9. bool found;
  10. int n;
  11. void dfs(unsigned __int64 x,int step)
  12. {
  13. if(found)
  14. return ;
  15. if(x%n==)
  16. {
  17. printf("%I64u\n",x);
  18. found=true;
  19. return ;
  20. }
  21. if(k==)
  22. return ;
  23. dfs(x*,step+);
  24. dfs(x*+,step+);
  25. }
  26. int main()
  27. {
  28. while(cin>>n,n)
  29. {
  30. found=false;
  31. dfs(,);
  32. }
  33. return ;
  34. }

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

  1.  

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. python3运行报错:TypeError: Object of type 'type' is not JSON serializable解决方法(详细)

    返回结果先转成str 字符创

  2. SQL SERVER视图对查询效率的提高

    SQL SERVER视图不仅可以实现许多我们需要的功能,而且对于SQL SERVER查询效率的提高也有帮助,下面一起来了解一下. 有两张数据表:A和B,其中A的记录为2万条左右,而B中的数据为200万 ...

  3. 2019牛客多校第六场 B - Shorten IPv6 Address 模拟

    B - Shorten IPv6 Address 题意 给你\(128\)位的二进制,转换为十六进制. 每\(4\)位十六进制分为\(1\)组,每两组用一个\(":"\)分开. 每 ...

  4. Unity编程标准导引-3.4 Unity中的对象池

    本文为博主原创文章,欢迎转载.请保留博主链接http://blog.csdn.net/andrewfan Unity编程标准导引-3.4 Unity中的对象池 本节通过一个简单的射击子弹的示例来介绍T ...

  5. soj#547 bzoj5046 分糖果游戏

    分析 代码 #include<bits/stdc++.h> using namespace std; #define int long long ; ][],s[],p[],v[]; si ...

  6. R 数据分析

    目录: windows命令行中执行R dataframe 常用函数.变量 1.windows命令行中执行R 前提:已经把R的命令目录加入了系统路径中. 在windows中,命令行执行R可以用以下两种方 ...

  7. getAttribute 与getParmeter 区别

    1.getAttribute是取得jsp中 用setAttribute設定的attribute 2.parameter得到的是string:attribute得到的是object 3.request. ...

  8. "如何用70行Java代码实现深度神经网络算法" 的delphi版本

     http://blog.csdn.net/hustjoyboy/article/details/50721535 "如何用70行Java代码实现深度神经网络算法" 的delphi ...

  9. taintCheck的实现

    参考:http://bitblaze.cs.berkeley.edu/papers/taintcheck-full.pdf 1. 应用taint analysis需要解决三个问题 a. 哪些input ...

  10. idea新手教程 如何springmvc创建Maven项目

    1.点击Create project,选择maven,勾选Create from archetype选择web-app,如图 2 输入    Group-Id     //组织名,也是作者名 Arti ...