内容简介:问题描述输出格式每个k占一行
问题描述
192这个数很厉害,用它分别乘以1、2、3,会得到:
192 x 1 = 192
192 x 2 = 384
192 x 3 = 576
把这三个乘积连起来,得到192384576,正好是一个1~9的全排列
我们把上面的运算定义为连接乘积:
m x (1 … n) = k(其中m > 0 且 n > 1,对于上例,m = 192、n = 3、k = 192384576)
即k是把m分别乘以1到n的乘积连接起来得到的,则称k为m和n的连接乘积。
输出格式
每个k占一行
样例输出
显然,结果中应包含一行:
192384576
#include <iostream>
using namespace std;
int gcd(int a, int b) {
if (b == 0) return a;
return gcd(b, a % b);
}
int main() {
int a, b, c, ans;
cin >> a >> b >> c;
ans = a * b / gcd(a, b);
ans = ans * c / gcd(ans, c);
cout << ans;
return 0;
}
❤❤点击这里 -> 订阅PAT、蓝桥杯、GPLT天梯赛、LeetCode题解离线版❤❤
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网
猜你喜欢:- 蓝桥杯 ADV-13 算法提高 最小乘积(提高型)
- 力扣152——乘积最大子序列
- Leetcode日记_01,乘积最大子序列
- 算法 - 找出数组中子集乘积的最大值
- LeetCode每日一题: 三个数的最大乘积(No.628)
- 如何备战蓝桥杯拿到省一
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Beautiful Code
Greg Wilson、Andy Oram / O'Reilly Media / 2007-7-6 / GBP 35.99
In this unique work, leading computer scientists discuss how they found unusual, carefully designed solutions to difficult problems. This book lets the reader look over the shoulder of major coding an......一起来看看 《Beautiful Code》 这本书的介绍吧!