POJ 1426 Find The Multiple(寻找倍数)

Time Limit: 1000MS    Memory Limit: 65536K

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.

给定一个整数n,敲个代码来找出n的仅有数字0和1构成的非零倍数m。你可以认为n不超过200且m不超过100个十进制数。

CN

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.

多组测试用例。每行有一个数n ( <= n <= )。某行一个0为输入结束。

CN

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.

对于每个输入的n,输出一行m。十进制数m必须不能超过100位。如果对于n存在多解,则随便输出一种。

CN

Sample Input - 输入样例

2
6
19
0

Sample Output - 输出样例

10
100100100100100100
111111111111111111

题解

  刚刚开始在想直接2^100可能有点问题,打算模拟除法来做…………然而水平太渣,写条件真是要死要活。(虽然可以出结果但是回溯/转移的时候没考虑好导致长度有问题……)
  发觉讨论里表示可以直接暴力出来……然后发现…………居然可以?!
  (估计数据不多)
  从100位开始发现可以刚好剪到19位,int64范围。
  不过似乎由于编译器对自动转换的支持问题,提交的时候要手动弄好int64才可以。

代码 C++

 #include <cstdio>
__int64 isFid, n;
void DFS(__int64 now, int len){
if (!isFid || len > ) return;
if (isFid = now%n){
DFS(now * , len + ); DFS(now * + , len + );
}
else printf("%I64d\n", now);
}
int main(){
while (scanf("%I64d", &n), isFid = n) DFS(, );
return ;
}

POJ 1426 Find The Multiple(寻找倍数)的更多相关文章

  1. POJ 1426 Find The Multiple --- BFS || DFS

    POJ 1426 Find The Multiple 题意:给定一个整数n,求n的一个倍数,要求这个倍数只含0和1 参考博客:点我 解法一:普通的BFS(用G++能过但C++会超时) 从小到大搜索直至 ...

  2. POJ.1426 Find The Multiple (BFS)

    POJ.1426 Find The Multiple (BFS) 题意分析 给出一个数字n,求出一个由01组成的十进制数,并且是n的倍数. 思路就是从1开始,枚举下一位,因为下一位只能是0或1,故这个 ...

  3. 广搜+打表 POJ 1426 Find The Multiple

    POJ 1426   Find The Multiple Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 25734   Ac ...

  4. DFS/BFS(同余模) POJ 1426 Find The Multiple

    题目传送门 /* 题意:找出一个0和1组成的数字能整除n DFS:200的范围内不会爆long long,DFS水过~ */ /************************************ ...

  5. POJ 1426 Find The Multiple (DFS / BFS)

    题目链接:id=1426">Find The Multiple 解析:直接从前往后搜.设当前数为k用long long保存,则下一个数不是k*10就是k*10+1 AC代码: /* D ...

  6. POJ 1426 Find The Multiple &amp;&amp; 51nod 1109 01组成的N的倍数 (BFS + 同余模定理)

    Find The Multiple Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 21436   Accepted: 877 ...

  7. POJ 1426 - Find The Multiple - [DP][BFS]

    题目链接:http://poj.org/problem?id=1426 Given a positive integer n, write a program to find out a nonzer ...

  8. POJ 1426 Find The Multiple(数论——中国同余定理)

    题目链接: http://poj.org/problem?id=1426 Description Given a positive integer n, write a program to find ...

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

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

随机推荐

  1. C# 自定义承载控件

    例如ToolStripTextBox类,里面的封装就是一个TextBox控件..NET的类库提供了ToolStripComBox和ToolStripProgressBar两个类.这些类都是从ToolS ...

  2. Docker相关知识整理

    一.进入和退出docker容器 使用docker ps查看容器id docker exec -it containerId /bin/bash //进入容器 Ctrl + P + Q //退出容器 二 ...

  3. 世界最顶级邮件服务器组合Linux + PMTA + OEMPRO,PowerMTA 安装

    世界最顶级邮件服务器组合Linux + PMTA + OEMPRO PowerMTA 安装 PMTA + OEMPRO  这个是发送的组合 PMTA提供的SMTP,OEMPRO是订阅管理以及邮件的过滤 ...

  4. 穿透内网,连接动态ip,内网ip打洞-----p2p实现原理(转)

    源: 穿透内网,连接动态ip,内网ip打洞-----p2p实现原理

  5. Hbuilder安装

    ---恢复内容开始--- ---恢复内容结束---

  6. VIM编码检查

    trouble shooting https://www.django.cn/article/show-4.html https://blog.csdn.net/lh756437907/article ...

  7. python基础--概念性问题

    面试其他篇 目录: 头条面试题:https://blog.csdn.net/m0_37947204/article/details/80103151 1.1 python常见基础题 1.遍历文件夹 # ...

  8. amqp 抓包

    1. wireshark 2. tcpick -yR -r  file.name

  9. linux command wrap

    $ cat tmux-attach ] ; then tmux ls else tmux attach -t $ fi $ cat /usr/bin/cscope-go.sh #!/bin/bash ...

  10. tf.nn.relu

    tf.nn.relu(features, name = None) 这个函数的作用是计算激活函数 relu,即 max(features, 0).即将矩阵中每行的非最大值置0. import tens ...