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. R语言︱数据分组统计函数族——apply族用法与心得

    每每以为攀得众山小,可.每每又切实来到起点,大牛们,缓缓脚步来俺笔记葩分享一下吧,please~ --------------------------- 笔者寄语:apply族功能强大,实用,可以代替 ...

  2. Java中的List转换成JSON报错(二)

    1.错误描述 Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/loggi ...

  3. WebForm 生成并显示二维码

    Generate and display QRCode in WebForm. 项目引用 QRCoder生成并显示 QRCode 项目引用 QRCoder How to use QRCoder Via ...

  4. StringBuilder的实现与技巧(转)

    1.Length   0.说明 在上一篇进一步了解String 中,发现了string的不便之处,而string的替代解决方案就是StringBuilder的使用 它的使用也很简单 System.Te ...

  5. css3动画结束捕捉事件整理

    //捕捉webkitAnimationEnd事件 element.addEventListener('webkitAnimationEnd', end, false); //捕捉webkitTrans ...

  6. FFT总结

    讲真的,FFT我只会背板子.其他就只能抓瞎了. [模板]FFT #include<cstdio> #include<algorithm> #include<cmath&g ...

  7. USACO08MAR Land Acquisition

    斜率优化 # include <stdio.h> # include <stdlib.h> # include <iostream> # include <s ...

  8. CodeIgniter怎么引入公共的头部或者尾部文件(实现随意引入或分区域创建header.html,bodyer.html,footer.html)

    除非你天赋异禀,凡事基本对任何人来说都是开头难的,且开头的事情如果没有做好 往往会打掉一个人对于某件事的希望及其激情,所以咱们先从容易的事情开始慢慢建立自己 信心.后面的事情咱们再慢慢推进. 如果你是 ...

  9. 论文笔记(9):Multiscale Combinatorial Grouping

    本文大致脉络: 对每张图片,作者首先使用 P. Doll´ar and C. Zitnick. Structured forests for fast edge detection. ICCV , 2 ...

  10. Asp.Net MVC 实现将Easy-UI展示数据下载为Excel 文件

    在一个项目中,需要做一个将Easy-UI界面展示数据下载为Excel文件的功能,经过一段时间努力,完成了一个小Demo.界面如下: 但按下导出Excel后,Excel文件将会下载到本地,在office ...