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. python 文件描述符

    先上一张图 文件描述符是内核为了高效管理已经被打开的文件所创建的索引, ----非负整数 ----用于指代被打开的文件 ----所有执行i/o操作的系统调用都是通过文件描述符完成的 进程通过文件描述符 ...

  2. httpclient get post

    https://www.cnblogs.com/wutongin/p/7778996.html post请求方法和get请求方法 package com.xkeshi.paymentweb.contr ...

  3. GUI界面相应事件

    function varargout = GUI19(varargin) % GUI19 MATLAB code for GUI19.fig % GUI19, by itself, creates a ...

  4. AtCoder Beginner Contest 045 C - たくさんの数式 / Many Formulas

    Time limit : 2sec / Memory limit : 256MB Score : 300 points Problem Statement You are given a string ...

  5. ELK学习笔记之简单适用的ES集群监控工具cerebro安装使用

    安装指导及使用简介 1.      下载安装包: https://github.com/lmenezes/cerebro/releases/download/v0.7.3/cerebro-0.7.3. ...

  6. 深入理解Word2Vec

    Word2Vec Tutorial - The Skip-Gram Model,Skip-Gram模型的实现原理:http://mccormickml.com/2016/04/19/word2vec- ...

  7. P2044 [NOI2012]随机数生成器

    洛咕原题 正常的矩乘题. 但是,计算过程中会爆long long. 所以,我们要用快速(龟速)乘来解决. 快速乘,也就是把快速幂稍作修改.乘法被分成若干个加法,以时间为代价解决精度问题. #inclu ...

  8. Apache正向代理和反向代理

    一.正向代理 先说一正向代理(Forward Proxy),通常普通用户使用的比较多的,是正向代理.也就是在浏览器的网络连接属性框中,填写上一个代理服务器的ip和端口,即可通过代理服务器中转,去浏览网 ...

  9. 【4opencv】识别复杂的答题卡1(主要算法)

    一.问题提出 由于GPY进行了纠偏,所以在采集的时候,就已经获得了质量较高的答题卡图片 下一步就是需要从这张图片中,识别出人眼识别出来的那些信息,并且将这个过程尽可能地鲁棒化,提高识别的准确率. 二. ...

  10. 20145308 《网络对抗》 MAL_后门应用与实践 学习总结

    20145308 <网络对抗> MAL_后门应用与实践 学习总结 实践目的 使用nc实现win和Linux间的后门连接 meterpreter的应用 MSF POST的应用 知识点学习总结 ...