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. 拼接SQL语句缺少“break”

    1.错误描述 [ERROR:]2015-07-20 16:42:21,734 [插入失败] org.hibernate.exception.SQLGrammarException: error exe ...

  2. Caused by: java.lang.ClassNotFoundException: org.jboss.logging.BasicLogger

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

  3. Crash CodeForces - 417B

    During the "Russian Code Cup" programming competition, the testing system stores all sent ...

  4. Java并发系列[8]----CyclicBarrier源码分析

    现实生活中我们经常会遇到这样的情景,在进行某个活动前需要等待人全部都齐了才开始.例如吃饭时要等全家人都上座了才动筷子,旅游时要等全部人都到齐了才出发,比赛时要等运动员都上场后才开始.在JUC包中为我们 ...

  5. 学习一之UML类图

    前言 最近在学习程杰老师的<大话设计模式>,觉得非常不错,就做了一些学习笔记和总结.如果对设计模式很感兴趣的,可以直接阅读书籍,相信会有更多的收获. 本人小菜一枚,如果理解的不对的还请多多 ...

  6. java实现中文分词

    IK Analyzer是基于lucene实现的分词开源框架 下载路径:http://so.csdn.net/so/search/s.do?q=IKAnalyzer2012.jar&t=doc& ...

  7. 分享到JavaScript

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  8. JavaScript保留关键字2。

    一些不做解释的关键字是在js中预留的东西. abstract 抽象  . arguments  参数 标识符arguments是指向实参对象的引用,实参对象是一个类数组对象. boolean 布尔值. ...

  9. [BZOJ2654] tree (kruskal & 二分答案)

    Description 给你一个无向带权连通图,每条边是黑色或白色.让你求一棵最小权的恰好有need条白色边的生成树. 题目保证有解. Input 第一行V,E,need分别表示点数,边数和需要的白色 ...

  10. 4.2 js没有块级作用域

    JavaScript没有块级作用域.在其他语言上,比如C语言中,有花括号封闭的代码块都有自己的作用域,(如果用ECMAScript的话来讲,就是他们自己的执行环境),因而支持根据条件来定义变量.例如, ...