Find The Multiple
Time Limit: 1000MS   Memory Limit: 10000K
Total Submissions: 22576   Accepted: 9291   Special Judge

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
    题目大意:找到n的一个倍数,并且这个数只由0 1组成。
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <cstring>
  4. #include <algorithm>
  5. using namespace std;
  6. int n;
  7. bool flag;
  8. unsigned long long m;
  9. void dfs(unsigned long long x,int k)
  10. {
  11. cout<<x<<endl;
  12. if(flag)
  13. return;
  14. if(x%n==)
  15. {
  16. flag=;
  17. m=x;
  18. return;
  19. }
  20. if(k==)
  21. return;
  22. dfs(x*,++k);
  23. dfs(x*+,k);
  24. return;
  25. }
  26. int main()
  27. {
  28. int i,j;
  29. while(cin>>n&&n)
  30. {
  31. flag=;
  32. dfs(,);
  33. cout<<m<<endl;
  34. }
  35. }

POJ Find The Multiple 1426 (搜索)的更多相关文章

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

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

  2. POJ 3126 Prime Path 广度优先搜索 难度:0

    http://poj.org/problem?id=3126 搜索的时候注意 1:首位不能有0 2:可以暂时有没有出现在目标数中的数字 #include <cstdio> #include ...

  3. [POJ]Find The Multiple(DFS)

    题目链接 http://poj.org/problem?id=1426 题意 输入一个数n,输出任意一个 只含0.1且能被n整除的数m.保证n<=200,m最多100位. 题解 DFS/BFS都 ...

  4. poj 1426 Find The Multiple (bfs 搜索)

    Find The Multiple Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 18012   Accepted: 729 ...

  5. POJ1426-Find The Multiple(搜索)

    Find The Multiple Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 42035   Accepted: 176 ...

  6. POJ 1088 滑雪 (记忆化搜索)

    题目链接:http://poj.org/problem?id=1088 题意很好懂,就是让你求一个最长下降路线的长度. dp[i][j]记录的是i j这个位置的最优的长度,然后转移方程是dp[i][j ...

  7. POJ 1321 棋盘问题 DFS搜索

    简单搜索 练习一下回溯 #include <iostream> #include <cstdio> #include <cstring> #include < ...

  8. POJ 1321 棋盘问题(搜索的方式)

    Description 在一个给定形状的棋盘(形状可能是不规则的)上面摆放棋子,棋子没有区别.要求摆放时任意的两个棋子不能放在棋盘中的同一行或者同一列,请编程求解对于给定形状和大小的棋盘,摆放k个棋子 ...

  9. POJ 1390 Blocks(记忆化搜索+dp)

    POJ 1390 Blocks 砌块 时限:5000 MS   内存限制:65536K 提交材料共计: 6204   接受: 2563 描述 你们中的一些人可能玩过一个叫做“积木”的游戏.一行有n个块 ...

随机推荐

  1. 使用git pull时,项目没有更新?

    进入项目目录后,执行 git pull 命令,没有将项目更新,并提示下图: 提示:there is no tracking information for the current branch. 意思 ...

  2. 【转】用Device tree overlay掌控Beaglebone Black的硬件资源

    原文网址:https://techfantastic.wordpress.com/2013/11/15/beaglebone-black-device-tree-overlay/ 经过一晚上的Goog ...

  3. 使用WCF实现SOA面向服务编程—— 架构设计

    原文地址:http://www.cnblogs.com/leslies2/archive/2011/03/29/1997889.html SOA本身就是一种面向企业级服务的系统架构,简单来说,SOA就 ...

  4. [转]ReactJS入门教程

    Refference From:http://www.cocoachina.com/webapp/20150721/12692.html 现在最热门的前端框架有AngularJS.React.Boot ...

  5. poj2787 算24

    每次枚举两个数,一个运算符,得到一个运算结果.在重复执行,直到只剩下一个数即可. #include <iostream> #include <cmath> using name ...

  6. POI导入数据

    package util; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.I ...

  7. 判断一个int 型整数 是否为回文数

    leetcode 上的题目 Determine whether an integer is a palindrome. Do this without extra space. 由于不能使用额外空间, ...

  8. Codeforces 549F Yura and Developers

    probelm 题意 给定一个序列和一个mod值,定义[l,r]合法当l到r的全部元素和减去当中的最大值的结果能够整除mod.问共同拥有多少区间合法. 思路 一開始想的分治. 对于一个[l,r]我们能 ...

  9. (2)入门指南——(3)为什么jquery工作的很好(Why jQuery works well)

    With the resurgence of interest in dynamic HTML comes a proliferation of JavaScript frameworks. Some ...

  10. 自定义上传按钮 <input type="file" name = "file"/> (将file隐藏在button下)

    <!DOCTYPE html><html><head><meta http-equiv="Content-Type" content=&q ...