The long-lost Sunday is coming again, and the ACM Laboratory Elimination Competition of Beihua University has begun. Now you have to complete a task: XLS is very happy, because IG won. Now to make him happy, just ask you to help him solve this problem, give you an n, let you find a multiple of M and m for n, but M has a limit. His number is only 0 or 1\. Can you help him solve this problem?

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

Each input you export a corresponding M, m does not know the unique number of m does not exceed 200 bits.

Sample Input

  1. 100
  2. 2

Sample Output

  1. 100
  2. 10
  1.  

题意理解:

老实说,我刚开始看了很久都没看懂==。其实题目的意思呐就是在1和0组成的数里面找n的倍数,这样是不是清晰多了,害

  1. DFS搜索法:
  1. #include<stdio.h>
  2. #include<iostream>
  3. #include<queue>
  4. #include<math.h>
  5. using namespace std;
  6.  
  7. long long n,now,cnt;
  8.  
  9. long long bfs(long long n)
  10. {
  11. queue<long long> q;
  12. q.push(1);
  13. while(q.size())
  14. {
  15. now=q.front();
  16. q.pop();
  17. cnt=(long long)log10(now)+1;
  18. // printf("yi--%lld %lld\n",cnt,now);
  19. if(cnt>200) break;
  20. if(now%n==0) return now;
  21. q.push(now*10);
  22. q.push(now*10+1);//若有其一除得尽,则return ;
  23. }
  24. return 0;
  25. }
  26.  
  27. int main()
  28. {
  29. while(cin>>n && n)
  30. {
  31. cnt=0;
  32. cout<<bfs(n)<<endl;
  33. }
  34. return 0;
  35. }
  1.  
  1.  

Find The Multiple 题解的更多相关文章

  1. [POJ2356]Find a multiple 题解(鸽巢原理)

    [POJ2356]Find a multiple Description -The input contains N natural (i.e. positive integer) numbers ( ...

  2. Problems to be upsolved

    Donation 官方题解尚未看懂. comet oj contest15 双11特惠hard Mobitel Small Multiple 题解 为什么可以如此缩点? Candy Retributi ...

  3. 题解报告:poj 1426 Find The Multiple(bfs、dfs)

    Description Given a positive integer n, write a program to find out a nonzero multiple m of n whose ...

  4. HDU 1019 Least Common Multiple 数学题解

    求一组数据的最小公倍数. 先求公约数在求公倍数.利用公倍数,连续求全部数的公倍数就能够了. #include <stdio.h> int GCD(int a, int b) { retur ...

  5. 题解 AT4164 【[ABC102A] Multiple of 2 and N】

    首先我们先来回忆一下小学一年级就学过的知识:任何一个偶数都是 \(2\) 的倍数,那么我们就可以分成两种情况考虑:奇数和偶数. 对于偶数,我们可以直接将其输出,因为它必定能被 \(2\) 与它自己整除 ...

  6. Lowest Common Multiple Plus 题解

    求n个数的最小公倍数. Input输入包含多个测试实例,每个测试实例的开始是一个正整数n,然后是n个正整数. Output为每组测试数据输出它们的最小公倍数,每个测试实例的输出占一行.你可以假设最后的 ...

  7. POJ 2356. Find a multiple 抽屉原理 / 鸽巢原理

    Find a multiple Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7192   Accepted: 3138   ...

  8. LeetCode Read N Characters Given Read4 II - Call multiple times

    原题链接在这里:https://leetcode.com/problems/read-n-characters-given-read4-ii-call-multiple-times/ 题目: The ...

  9. NBUT1541 Rainwater 题解

    http://cdn.ac.nbutoj.com/Problem/view.xhtml?id=1541 When rain, nocLyt discovered a magical phenomeno ...

  10. Find The Multiple 分类: 搜索 POJ 2015-08-09 15:19 3人阅读 评论(0) 收藏

    Find The Multiple Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 21851 Accepted: 8984 Sp ...

随机推荐

  1. 【第4个渗透靶机项目】 Tr0ll

    每天都要加油哦! 0x00  信息搜集 首先找到一下靶机的ip,并扫描端口. 靶机和kali都是桥接. 那么先看一下kali的ifconfig信息. nmap -sn 192.168.0.0/24  ...

  2. JVM底层原理

    目录 1.类加载器与ClassFileFormate 2.JVM内存模型 3.对象在JVM中的创建与内存分配 4.对象引用与垃圾回收算法 5.JVM垃圾回收 6.G1垃圾回收器 7.ZGC垃圾回收器

  3. Java开发中PO、VO、DAO、BO、DTO、POJO 含义

    PO(persistant object) 持久对象 可以看成是与数据库中的表相映射的java对象.使用 Mybatis 来生成 PO 是不错的选择. VO(value object) 值对象 通常用 ...

  4. python实现zip分卷压缩与解压

    1. python实现zip分卷压缩 WinHex 开始16进制一个一个文件对比 WinRar 创建的分卷压缩和单个 zip 文件的差异. 如果想把单个大文件 test.zip -> 分卷文件  ...

  5. 在数据增强、蒸馏剪枝下ERNIE3.0分类模型性能提升

    在数据增强.蒸馏剪枝下ERNIE3.0模型性能提升 项目链接: https://aistudio.baidu.com/aistudio/projectdetail/4436131?contributi ...

  6. 如何在Visual Studio新C++项目中调用之前配置过的库?

      本文介绍在Visual Studio软件中调用C++各种配置.编译完毕的第三方库的方法.   在撰写C++代码时,如果需要用到他人撰写的第三方库(例如地理数据处理库GDAL.矩阵运算库Armadi ...

  7. Asp.net平台常用的框架整理

    分布式缓存框架: Microsoft Velocity:微软自家分布式缓存服务框架. Memcahed:一套分布式的高速缓存系统,目前被许多网站使用以提升网站的访问速度. Redis:是一个高性能的K ...

  8. 一篇带你掌握cmake入门|了解cmake|掌握cmake基本操作

    一篇带你掌握cmake入门 内容出处: 作者: 苏丙榅 链接: https://subingwen.cn/cmake/CMake-primer/ 来源: 爱编程的大丙 著作权归作者所有.商业转载请联系 ...

  9. Linux中国开源社区停止运营

    layout: post title: "Linux 中国开源社区停止运营" tags: - "Linux" 昨天看到老王发的公众号文章,Linux中国开源社区 ...

  10. 使用ethtool排查网卡速率问题

    今天去现场帮一个客户排查备份网络速率问题. 用户期望是万兆的速率,但实际上目前只有千兆,因为目前上面运行着数据库,且数据量较大,千兆的备份网络速率不能满足用户备份数据库的时长要求. 首先,确认备份网络 ...