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. PHP_保留两位小数并且四舍五入_保留两位小数并且不四舍五入

    php保留两位小数并且四舍五入 $num = 123213.666666; echo sprintf("%.2f", $num); php保留两位小数并且不四舍五入 php进一法取 ...

  2. VxWorks 基本启动方式

    VxWorks 基本启动方式     按VxWorks内核的下载形式,VxWorks启动总体上分为两种方式:下载型和ROM 型.     @下载型启动方式:bootrom+VxWorks.此时boot ...

  3. AM335x(TQ335x)学习笔记——USB驱动移植

    对于AM335x来讲,TI维护的USB驱动已经非常完善了,本文称之为移植,实际上仅仅是配置内核选项使能USB HOST/OTG功能.废话少说,直接动手开启AM335x的USB驱动配置项. Step1. ...

  4. Error Code: 1068. Multiple primary key defined

    1.错误描述 10:10:38 alter table user add num int(8) primary key first Error Code: 1068. Multiple primary ...

  5. Cookie操作类、压缩、序列化

    1.cookie类 CartCookie.cs using System; using System.Data; using System.Configuration; using System.We ...

  6. Java 第六章

    第六章 for语法:for(表达式①;表达式②;表达式③){ //④循环操作}表达式含义:表达式1:赋值语句, 它用来给循环变量赋初值 例如:int i = 1;表达式2:循环条件,一个关系表达式, ...

  7. httpclient案例一(调用识别接口)

    public Map<String, Object> pictureRecognition(String recotype, MultipartFile imageFile) { Stri ...

  8. 一篇关于PHP性能的文章

    一篇关于PHP性能的文章 昨晚清理浏览器收藏夹网址时,发现了http://www.phpbench.com/,想起来应该是2015年发现的一个比较性能的文章,我就点进去看了看,发现还是全英文耶,刚好最 ...

  9. json 的循环输出

    json不能用for-of循环,会报错 可以用for-in循环: var json = {'a':'apple','b':'banana','c':'orange','d':'pear'}; for( ...

  10. 使用Spring-boot小结

    Spring-boot的特点是,通过注入的方式生成FsShell对象,来操作HDFS,其底层封装了HDFS的的shell命令 1. 添加Spring-boot依赖 pom.xml文件 <!--添 ...