Smallest multiple
problem 5:Smallest multiple
题意:求最小的正数,使得其可以被1-20整除
代码如下:
#ifndef PRO5_H_INCLUDED
#define PRO5_H_INCLUDED
#include "prime.h"
namespace pro5{
long long solve(){
;
;i<=;++i)
ans=lcm(ans,i);
return ans;
}
}
#endif // PRO5_H_INCLUDED
有关函数:
long long gcd(long a,long b){
?a:gcd(b,a%b);
}
long long lcm(long a,long b){
return a/gcd(a,b)*b;
}
Smallest multiple的更多相关文章
- projecteuler Smallest multiple
2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any rema ...
- (Problem 5)Smallest multiple
2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any rema ...
- Problem 5: Smallest multiple
2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any rema ...
- Types of compression algorithms
http://www.html5rocks.com/en/tutorials/speed/img-compression/ Types of compression algorithms There ...
- PE 001~010
题意: 001(Multiples of 3 and 5):对小于1000的被3或5整除的数字求和. 002(Even Fibonacci numbers):斐波那契数列中小于等于4 000 000的 ...
- Alignment And Compiler Error C2719 字节对齐和编译错误C2719
Compiler Error C2719 'parameter': formal parameter with __declspec(align('#')) won't be aligned The ...
- Problem5-Project Euler
Smallest multiple 2520 is the smallest number that can be divided by each of the numbers from 1 to ...
- Project Euler Problem5
Smallest multiple Problem 5 2520 is the smallest number that can be divided by each of the numbers f ...
- CUDA C Programming Guide 在线教程学习笔记 Part 10【坑】
▶ 动态并行. ● 动态并行直接从 GPU 上创建工作,可以减少主机和设备间数据传输,在设备线程中调整配置.有数据依赖的并行工作可以在内核运行时生成,并利用 GPU 的硬件调度和负载均衡.动态并行要求 ...
随机推荐
- Ubuntu下编译程序是出现pthread_create未定义错误
gcc -c node_list.c -o node_list.o gcc -lpthread sim.o cli.o list.o node_list.o -o sim.exe sim.o: In ...
- mysql的事物
所谓的事物就是一组原子性的SQL语句,或者说是一个独立的工作单元. 1.事物拥有四大特征: ①原子性(atomicity):一个事物必须被分为一个不可分割的的最小单元,整个事物中的所有操作要么全部提交 ...
- ubuntu下的词典的安装
因为从事开发,安装一个词典是很有必要,文中介绍安装openyoudao和stardic两个软件的方法 一.openyoudao的安装 因为是由window转来学ubuntu的,所以总是想安装和wind ...
- leetcode[88] Gray Code
题目:格雷码. 格雷码是从0开始且之后两个相邻码之间只有一个符号不相同,例如000,100,101,111三个相邻之间只有一个二进制不同. 现在给定一个数字n,然后给出格雷码所对应的数字.例如: Fo ...
- svn搭建
原文:svn搭建 二.Subversion的安装与测试 Subversion的配置方式有很多种,同时也可以配置不同的操作系统之上,本文我讲解的是Subversion 1.5.4 for Apache2 ...
- 配置serv-u access数据库遇到的一些问题
配置好access数据库后,需要建个web页面来供用户修改密码,但修改时,提示:odbc被占用无法打开. serv-u一直在保持打开access数据库.我们需要将数据库设置默认打开方式为共享,不锁定. ...
- php中使用随机数
<?phpsession_start();$s = array("a","b","c","d","e&q ...
- ODBC操作数据库
/*ODBC使用步骤:(ODBC数据源由微软平台提供) * 1.配置ODBC数据源(控制面板->管理工具->ODBC数据源) * 2.加载并注册驱动程序,导入java.sql.*包 * 3 ...
- Dom解析xml源代码
import java.io.File; import java.io.IOException; import javax.xml.parsers.DocumentBuilder; import ja ...
- 分享一个c#写的开源分布式消息队列equeue
分享一个c#写的开源分布式消息队列equeue 前言 equeue消息队列中的专业术语 Topic Queue Producer Consumer Consumer Group Broker 集群消费 ...