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 的硬件调度和负载均衡.动态并行要求 ...
随机推荐
- js实现是倒计时功能
工作中经常用到倒计时的功能,最近在整理之前做的项目的时候,发现自己写过一个倒计时的功能的效果,这里和大家分享下!实现这个功能是用原生js写的,不需要加载额外的库文件!功能比较简单,但是可以在此基础上扩 ...
- VS SQL 出现%CommonDir%dte80a.olb 该解决方案
VS SQL 出现%CommonDir%dte80a.olb 该解决方案 在网上搜索解决方法的时候.别人就说你从别的电脑复制一个到C:\Program Files\Common Files\mic ...
- 【转载】如何让Chrome浏览器允许本地环境支持Ajax
转载自:http://www.bewxx.com/news/news_89.html 对于网站前端人员来说,我们在本地开发程序的时候如果用到Ajax的话,通常会使用Firefox来测试,因为Firef ...
- 仿async/await(一)and Gulp:新一代前端构建利器
NET 4.5的async/await真是个神奇的东西,巧妙异常以致我不禁对其实现充满好奇,但一直难以窥探其门径.不意间读了此篇强文<Asynchronous Programming in C# ...
- c#中关于大对象数组的一些心得
在之前的一个课题中,曾经需要用到2W行*3W列的float类型矩阵(大约2.4G),由于无法创建大于2G的对象,当时采用了一些取巧的办法回避了,并没有拿出精力来研究一下这个问题.今天和公司的张哥(大牛 ...
- POJ 1002 UVA 755 487--3279 电话排序 简单但不容易的水题
题意:给你许多串字符串,从中提取电话号码,输出出现复数次的电话号码及次数. 以下是我艰难的AC历程:(这题估计是我刷的题目题解次数排前的了...) 题目不是很难理解,刚开始想到用map,但stl的ma ...
- queue,指针求最短路的区别
这里以spfa为例://都用邻接表存边: 指针: int h=1,t=1; q[h]=x; while(h<=t){ int u=q[h]; vis[u]=0; for(int i=head[u ...
- CoreSeek Sphinx 安装
1.centos Sphinx 先安装 yum install postgresql-libs yum install unixODBC CoreSeek 安装: http://www.coresee ...
- android Fragment 用法小结
Fragment 是android 3.0引入的新API,是作为Activity的子模块,必须嵌入Activity才能使用. Activity 与 Fragment的关系: 一.依附性: 1. Fra ...
- Paint与Canvas的简单用法
参考:http://www.eoeandroid.com/forum.php?mod=viewthread&tid=278237 自定义View 重写onDraw方法 package com. ...