Find The Multiple
Time Limit: 1000MS   Memory Limit: 10000K
Total Submissions: 41845   Accepted: 17564   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

2
6
19
0

Sample Output

10
100100100100100100
111111111111111111

Source

题意:找出一个最小的由1或者0组成的十进制数能整除n
题解:dfs,一开始看题目说十进制数会达到100位,其实不会,在longlong的范围内,下次遇到这种可以直接打表找一下规律
代码:
#include<iostream>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
const ll mod=;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
//head
#define MAX 1000
int n;
int flag;
void dfs(int cur,ll sum)
{
if(cur==)return ;
if(flag) return ;
if(sum%n==&&sum!=)
{
flag=;
cout<<sum<<endl;
return ;
}
else
dfs(cur+,sum*),dfs(cur+,sum*+);
}
int main()
{
cin.tie();
cout.tie();
ios::sync_with_stdio();
while(cin>>n)
{
if(n==)break;
flag=;
dfs(,);
}
return ;
}

最新文章

  1. opencv2.4.9在ubuntu(树莓派)上安装
  2. [ActionScript 3.0] 通过三角形获得 3D 效果
  3. Android学习之Activity初步
  4. js_BOM_05
  5. HTML5的你应该记住的一些知识点
  6. How Many Tables--hdu1213(并查集)
  7. HTML阶段总结
  8. WebView 简介
  9. 详解Java的Spring框架中的注解的用法
  10. bcftools将vcf生成bgzip和index格式
  11. Oracle 25用户的权限管理
  12. Java中当前对象引用
  13. Private表示该属性(方法)为只有本类内部可以访问(类内部可见)。
  14. Java Deadlock Example and How to analyze deadlock situation
  15. excel的列生成算法
  16. 用HTML编写阿里云
  17. mysq5.7
  18. django views.py视图 获取用户请求相关信息以及请求头
  19. (转)Inno Setup入门(九)——修改安装过程中的文字显示
  20. 解决Myeclipse编译不生成.class文件问题

热门文章

  1. 实现combobox模糊查询的时候报错 InvalidArgument=“0”的值对于“index”无效
  2. 20個命令行工具監控 Linux 系統性能
  3. Vue-列表渲染 非变异方法
  4. ltp-ddt smp_basic
  5. SQL的各种连接--自联结,内连接,外连接,交叉连接
  6. zoj 3325 Machine(线段树)
  7. vue中路由传参的方式
  8. 英语单词deprecated
  9. pycharm 进入Pythonshell脚本调试
  10. php ucwords()函数 语法