Find The Multiply
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的更多相关文章
- Multiply Strings
Given two numbers represented as strings, return multiplication of the numbers as a string. Note: Th ...
- [LeetCode] Multiply Strings 字符串相乘
Given two numbers represented as strings, return multiplication of the numbers as a string. Note: Th ...
- 43. Multiply Strings
/** * @param {string} num1 * @param {string} num2 * @return {string} */ var multiply = function(num1 ...
- LeetCode:Multiply Strings
题目链接 Given two numbers represented as strings, return multiplication of the numbers as a string. Not ...
- Numpy Study 2----* dot multiply区别
使用numpy时,跟matlab不同: 1.* dot() multiply() 对于array来说,* 和 dot()运算不同 *是每个元素对应相乘 dot()是矩阵乘法 对于matrix来说,* ...
- 【leetcode】Multiply Strings
Multiply Strings Given two numbers represented as strings, return multiplication of the numbers as a ...
- LeetCode(43. Multiply Strings)
题目: Given two numbers represented as strings, return multiplication of the numbers as a string. Note ...
- [CareerCup] 7.4 Implement Multiply Subtract and Divide 实现乘法减法和除法
7.4 Write methods to implement the multiply, subtract, and divide operations for integers. Use only ...
- Java for LeetCode 043 Multiply Strings
Given two numbers represented as strings, return multiplication of the numbers as a string. Note: Th ...
- Multiply Strings [LeetCode]
Problem Description http://oj.leetcode.com/problems/multiply-strings/ Basic idea is to multiply two ...
随机推荐
- R语言︱集合运算——小而美法则
每每以为攀得众山小,可.每每又切实来到起点,大牛们,缓缓脚步来俺笔记葩分享一下吧,please~ --------------------------- 集合运算的一般规则如下: union(x ...
- zTree实现更新根节点中第i个节点的名称
zTree实现更新根节点中第i个节点的名称 1.实现源码 <!DOCTYPE html> <html> <head> <title>zTree实现基本树 ...
- ssh_Connection reset by peer报错
连接SSH时,产生了一下错误----->Read from socket failed: Connection reset by peer 首先查看日志 tail -f /var/log/aut ...
- iOS - MySQL 的安装配置
前言 提前下载好相关软件,且安装目录最好安装在全英文路径下.如果路径有中文名,那么可能会出现一些莫名其妙的问题. 提前准备好的软件: mysql-5.7.17-macos10.12-x86_64.dm ...
- banner图片轮播
html部分 版本号 <script src="http://www.jq22.com/jquery/jquery-1.10.2 ...
- [SCOI2010]股票交易
题目大意: 网址:https://www.luogu.org/problemnew/show/P2569 大意:在接下来的T天中,每天股票有一个买入价格Api与卖出价格Bpi. 同时,每天买入股票数与 ...
- c++面试遇到问题
1. C 和 C++ 区别 2. const 有什么用途 主要有三点: 1:定义只读变量,即常量 2:修饰函数的参数和函数的返回值 3: 修饰函数的定义体,这里的函数为类的成员函数, ...
- hadoop第二课
1.1为什么需要Hadoop (1)数据分析者面临的问题 – 数据日趋庞大,读写都出现性能瓶颈: – 用户的应用和分析结果,对实时性和响应时间 要求越来越高: – 使用的模型越来越复杂,计算量指数级 ...
- VMware Workstation 14 Pro永久激活密钥
1. ZC3WK-AFXEK-488JP-A7MQX-XL8YF 2. AC5XK-0ZD4H-088HP-9NQZV-ZG2R4 3. ZY5H0-D3Y8K-M89EZ-AYPEG-MYUA8 4 ...
- CYQ.data 框架结构
-------------------------V5.0开始(刚开始过滤版本:有些更新功能迁到V4,所以记录在V4那)-----------------------------7:Insert方法增 ...