project euler 5
来源:互联网 发布:淘宝上情趣用品买家秀 编辑:程序博客网 时间:2024/05/21 06:24
题目:
https://projecteuler.net/problem=5
题意:
Smallest multiple
Problem 5
2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.
What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?
求1~20这20个数字的最小公倍数
思路:
初始化
代码:
#include <bits/stdc++.h>using namespace std;int gcd(int a, int b){ return !b ? a : gcd(b, a%b);}int lcm(int a, int b){ return a / gcd(a, b) * b;}int main(){ int ans = 1; for(int i = 1; i <= 20; ++i) ans = lcm(ans, i); printf("%d\n", ans); return 0;}
阅读全文
0 0
- Project Euler - Problem 5
- Project Euler-5
- Project Euler problem 5
- Project Euler 5
- Project Euler 1~5
- Project Euler 5
- Project Euler - 5
- project euler 5
- Project Euler Problem1-5
- project euler 5
- 【Project Euler】5 第五题
- Python实现Project Euler 5
- Project Euler 1-5题
- Project Euler
- project euler
- Project Euler
- 【Project Euler】【Problem 5】Smallest multiple
- project euler problem 5:Smallest multiple
- 俯瞰tcp协议的三次握手
- RabbitMQ在Centos7中安装及使用
- Kotlin入坑(五)类和继承二
- 关于eclipse中js文件没有提示代码的解决
- hbase1.3配置snappy压缩
- project euler 5
- [JZOJ4695]【GDOI2017模拟8.14】佐助的难题
- 【机器学习】Sklearn独热编码one hot 编码preprocessing.OneHotEncoder()使用
- opencv: cv2.applyColorMap 伪色彩
- FFMPEG 之音频解码及AudioTrack播放音频
- Linux编辑器--简单说
- Machine动画脚本自动生成AnimatorController
- 一分钟解决Shape分割线及分割线圆角框
- CDH CSD and Upgrade