Find The Multiply poj-1426

    题目大意:给你一个正整数n,求任意一个正整数m,使得n|m且m在十进制下的每一位都是0或1。

    注释:n<=200。

      想法:看网上的题解全是bfs乱搜(其实我的做法也是bfs),我来说一说我这简单的bfs。其实这道题的精髓就在于如何考虑对于大数的处理。显然,我们可以用同余mod定理来搞定。

    最后,附上丑陋的代码... ...

 #include <iostream>
#include <cstdio>
using namespace std;
long long ans[];
int main()
{
int n;
while(~scanf("%d",&n))
{
if(n==) return ;
for(int i=;;i++)
{
ans[i]=ans[i/]*+i%;
if(ans[i]%n==)
{
break;
}
}
printf("%I64d\n",ans[i]);
}
}

    小结:定理的充分运用才是重要的... ...

Find The Multiply的更多相关文章

  1. Multiply Strings

    Given two numbers represented as strings, return multiplication of the numbers as a string. Note: Th ...

  2. [LeetCode] Multiply Strings 字符串相乘

    Given two numbers represented as strings, return multiplication of the numbers as a string. Note: Th ...

  3. 43. Multiply Strings

    /** * @param {string} num1 * @param {string} num2 * @return {string} */ var multiply = function(num1 ...

  4. LeetCode:Multiply Strings

    题目链接 Given two numbers represented as strings, return multiplication of the numbers as a string. Not ...

  5. Numpy Study 2----* dot multiply区别

    使用numpy时,跟matlab不同: 1.* dot() multiply() 对于array来说,* 和 dot()运算不同 *是每个元素对应相乘 dot()是矩阵乘法 对于matrix来说,* ...

  6. 【leetcode】Multiply Strings

    Multiply Strings Given two numbers represented as strings, return multiplication of the numbers as a ...

  7. LeetCode(43. Multiply Strings)

    题目: Given two numbers represented as strings, return multiplication of the numbers as a string. Note ...

  8. [CareerCup] 7.4 Implement Multiply Subtract and Divide 实现乘法减法和除法

    7.4 Write methods to implement the multiply, subtract, and divide operations for integers. Use only ...

  9. Java for LeetCode 043 Multiply Strings

    Given two numbers represented as strings, return multiplication of the numbers as a string. Note: Th ...

  10. Multiply Strings [LeetCode]

    Problem Description http://oj.leetcode.com/problems/multiply-strings/ Basic idea is to multiply two ...

随机推荐

  1. Flex和Servlet结合上传文件

    Flex和Servlet结合上传文件 1.准备工作 (1)下载文件上传的组件,commons-fileupload-1.3.1.jar (2)下载文件输入输出jar,commons-io-2.4.ja ...

  2. Error Code: 1175. You are using safe update mode and you tried to update a table

    错误描述 11:14:39 delete from t_analy_yhd Error Code: 1175. You are using safe update mode and you tried ...

  3. Netty的并发编程实践2:volatile的正确使用

    长久以来大家对于volatile如何正确使用有很多的争议,既便是一些经验丰富的Java设计师,对于volatile和多线程编程的认识仍然存在误区.其实,volatile的使用非常简单,只要理解了Jav ...

  4. SecurityError:Error:#2148

    1.错误描述 SecurityError:Error:#2148:SWF文件http://localhost:8888/UploadDownload/Flash/ReadLocalFile.swf/[ ...

  5. Java和Flex整合报错(二)

    1.错误原因 usage: java org.apache.catalina.startup.Catalina [ -config {pathname} ] [ -nonaming ] { -help ...

  6. google浏览器插件推荐

    http://www.tuicool.com/articles/eQ32Ur http://blog.jobbole.com/1386/ https://www.oschina.net/news/46 ...

  7. 玲珑杯#2.5 A-B

    这个题解错了网上还没有题解 囧 = (i%2)? 1 : -1 = - * * *= m #include<bits/stdc++.h> using namespace std; type ...

  8. 如何登录mysql? cmd怎么连接mysql数据库||从MYSQL客户端登录MYSQL

    1 2 3 4 5 6 7 分步阅读 Mysql开源数据库,任何人都可以下载安装使用.那么安装好的mysql如何登陆连接mysql数据库呢?本经验咗嚛介绍几种常见的方法 工具/原料   mysql 连 ...

  9. MFC 中线程传递CString 是不安全的 转

     MFC 中线程传递CString 是不安全的       在MFC中,向线程传递CString变量参数时,很容易犯一个错误,就是使用一个超出生存期的变量,在主函数中定义的CString变量是局部变量 ...

  10. C#图解教程 第二十一章 命名空间和程序集

    命名空间和程序集 引用其他程序集 mscorlib库 命名空间 命名空间名称命名空间的补充命名空间跨文件伸展嵌套命名空间 using 指令 using命名空间指令using别名指令程序集的结构 程序集 ...