Find The Multiple

 

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

Source

 
  1. //2017-02-23
  2. #include <iostream>
  3. #include <cstdio>
  4. #include <cstring>
  5.  
  6. using namespace std;
  7.  
  8. int ans[], n;
  9. bool ok;
  10.  
  11. void dfs(unsigned long long num, int pos)
  12. {
  13. if(ok || pos == )return;
  14. if(num%n==){
  15. cout<<num<<endl;
  16. ok = true;
  17. return;
  18. }else{
  19. dfs(num*, pos+);
  20. dfs(num*+, pos+);
  21. }
  22. }
  23.  
  24. int main()
  25. {
  26. while(cin>>n && n)
  27. {
  28. ok = false;
  29. dfs(, );
  30. }
  31.  
  32. return ;
  33. }

POJ1426(KB1-E 暴力搜索)的更多相关文章

  1. ACM 暴力搜索题 题目整理

    UVa 129 Krypton Factor 注意输出格式,比较坑爹. 每次要进行处理去掉容易的串,统计困难串的个数. #include<iostream> #include<vec ...

  2. hdu 4740 The Donkey of Gui Zhou(暴力搜索)

    题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=4740 [题意]: 森林里有一只驴和一只老虎,驴和老虎互相从来都没有见过,各自自己走过的地方不能走第二次 ...

  3. hdu 1427 速算24点 dfs暴力搜索

    速算24点 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Problem De ...

  4. 随手练——洛谷-P1151(枚举与暴力搜索)

    枚举 #include <iostream> using namespace std; int main() { ; cin >> k; ; i < ; i++) { ) ...

  5. 枚举进程——暴力搜索内存(Ring0)

    上面说过了隐藏进程,这篇博客我们就简单描述一下暴力搜索进程. 一个进程要运行,必然会加载到内存中,断链隐藏进程只是把EPROCESS从链表上摘除了,但它还是驻留在内存中的.这样我们就有了找到它的方法. ...

  6. [luogu 1092] 虫食算 (暴力搜索剪枝)

    传送门 Description Input 包含四行. 第一行有一个正整数 (N≤26). 后面的三行,每行有一个由大写字母组成的字符串,分别代表两个加数以及和.这3个字符串左右两端都没有空格,从高位 ...

  7. HDU 3131 One…Two…Five! (暴力搜索)

    题目链接:pid=3131">HDU 3131 One-Two-Five! (暴力搜索) 题意:给出一串数字,要求用加,减,乘,除(5/2=2)连接(计算无优先级:5+3*6=8*6= ...

  8. 吴裕雄 python 机器学习——模型选择参数优化暴力搜索寻优GridSearchCV模型

    import scipy from sklearn.datasets import load_digits from sklearn.metrics import classification_rep ...

  9. POJ 1129:Channel Allocation 四色定理+暴力搜索

    Channel Allocation Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 13357   Accepted: 68 ...

  10. 「状压DP」「暴力搜索」排列perm

    「状压DP」「暴力搜索」排列 题目描述: 题目描述 给一个数字串 s 和正整数 d, 统计 sss 有多少种不同的排列能被 d 整除(可以有前导 0).例如 123434 有 90 种排列能被 2 整 ...

随机推荐

  1. Stack-682. Baseball Game

    You're now a baseball game point recorder. Given a list of strings, each string can be one of the 4 ...

  2. 一,memcached的基本概念

    1,memcached的基本概念 memcached是一个高效的分布式内存对象缓存系统,它可以支持把各种php的数据(array,对象,基本数据类型)放入到它管理的内存中.简单的说,memcached ...

  3. 程序猿的日常——Java基础之抽象类与接口、枚举、泛型

    再次回顾这些基础内容,发现自己理解的又多了一点.对于一些之前很模糊的概念,渐渐的清晰起来. 抽象类与接口 抽象类通常是描述一些对象的通用方法和属性,并且默认实现一些功能,它不能被实例化.接口仅仅是描述 ...

  4. MYSQL NULL值特性

    NULL是一种“没有类型”的值,通常表示“无值”,“未知值”,“缺失值”,“超界”,“不在其中”等,我们在日常运用中很容易和NULL字符串混淆,这里大致整理了下NULL值的一些特性,以便能够正确使用N ...

  5. 【hdu4609】 3-idiots FFT

    题外话:好久没写blog了啊-- 题目传送门 题目大意:给你m条长度为ai的线段,求在其中任选三条出来,能构成三角形的概率.即求在这n条线段中找出三条线段所能拼出的三角形数量除以$\binom{m}{ ...

  6. jq03--基础函数

    我们继续学习jq的一些函数,包括向jq对象添加.删除CSS属性以及遍历DOM树. 1.获取.设置CSS类 addClass()--向被选元素添加1个或多个类属性 .importance{font-we ...

  7. 使用webpack打包js文件(隔行变色案例)

    使用webpack打包js文件(隔行变色案例) 1.webpack安装的两种方式 运行npm i webpack -g全局安装webpack,这样就能在全局使用webpack的命令 在项目根目录中运行 ...

  8. DotNetOpenAuth 使用指南

    这几天一直在研究DotNetOpenAuth,源码处处是坑啊!写此文只为大家更顺利掌握DotNetOpenAuth使用方法,尽量少走弯路. 说明一下:我的环境是Win7 64   VS2015 upd ...

  9. 【数组】Search for a Range

    题目: Given a sorted array of integers, find the starting and ending position of a given target value. ...

  10. Struts文件上传(FormFile)

    Struts中FormFile用于文件进行上传 1.在jsp文件中进行定义 <form action="/StrutsFileUpAndDown/register.do" m ...