当前位置:网站首页>Code hoof collection of wonderful secret place
Code hoof collection of wonderful secret place
2022-07-04 14:06:00 【Elvin domain text】
subject : The adventure group is exploring in a wonderful secret place , In front of us is the secret place reward level , The checkpoint mechanism is as follows : Random given M Gold coin , If you can find three that are not greater than M The integer of ( Can be the same ), Find their least common multiple S, Then the adventure group can get S Gold coins , In order to get the most gold coins , It is unanimously decided that you, the team think tank, will be entrusted with the task , Find out S The maximum of .
Format :
Input format : Enter a positive integer n
Output format : Output the least common multiple of the three numbers in the question S The maximum of
Examples :
Input :10 Output :630
#include<bits/stdc++.h>
using namespace std;
int main(){
long long int n;
vector<long long int> arr;
vector<long long int> arr2;
long long int temp, c, d;
long long int min,min2;
bool flag;
cin >> n;
if(n > 2) {
arr.insert(arr.end(),n);
arr.insert(arr.end(), n-1);
arr.insert(arr.end(),n-2);
sort(arr.begin(), arr.end());
while(arr.size()>1){
c = arr[0];
d = arr[1];
min = c*d;
// cout << min << endl; The two elements are the same
temp = c%d;
while(temp){
c = d;
d = temp;
temp = c%d;
}
min = min/d;
arr.erase(arr.begin(),arr.begin()+2);
arr.insert(arr.begin(),min);
}
if(n-3>0){
flag = 1;
arr2.insert(arr2.end(),n);
arr2.insert(arr2.end(), n-1);
arr2.insert(arr2.end(),n-3);
sort(arr2.begin(),arr2.end());
while(arr2.size()>1){
c = arr2[0];
d = arr2[1];
min2 = c*d;
temp = c%d;
// for(int i=0;i<arr2.size();i++){
// cout << arr2[i] << endl;
// }
while(temp){
c = d;
d = temp;
temp = c%d;
}
min2 = min2/d;
arr2.erase(arr2.begin(),arr2.begin()+2);
arr2.insert(arr2.begin(),min2);
}
}
if(flag){
if(min2 > min) {
min = min2;
}
}
}
else{
if(n==2){
min = 4;
}
else{
min =1;
}
}
cout << min;
return 0;
}
边栏推荐
- Dgraph: large scale dynamic graph dataset
- Yingshi Ruida rushes to the scientific and Technological Innovation Board: the annual revenue is 450million and the proposed fund-raising is 979million
- BLOB,TEXT GEOMETRY or JSON column 'xxx' can't have a default value query 问题
- sharding key type not supported
- 硬件基础知识-二极管基础
- Unittest框架中引入TestFixture
- Unittest中的TestSuite和TestRunner
- Redis - how to install redis and configuration (how to quickly install redis on ubuntu18.04 and centos7.6 Linux systems)
- 2022G3锅炉水处理考试题模拟考试题库及模拟考试
- 担心“断气” 德国正修改《能源安全法》
猜你喜欢

2022年山东省安全员C证考试题库及在线模拟考试

字节面试算法题

markdown 语法之字体标红

数据库公共字段自动填充

中邮科技冲刺科创板:年营收20.58亿 邮政集团是大股东

【Antd】Antd 如何在 Form.Item 中有 Input.Gourp 时获取 Input.Gourp 的每一个 Input 的value

德明利深交所上市:市值31亿 为李虎与田华夫妻档

吃透Chisel语言.10.Chisel项目构建、运行和测试(二)——Chisel中生成Verilog代码&Chisel开发流程

嵌入式编程中五个必探的“潜在错误”

【Antd踩坑】Antd Form 配合Input.Group时出现Form.Item所占据的高度不对
随机推荐
C语言个人通讯录管理系统
Huahao Zhongtian sprint Technology Innovation Board: perte annuelle de 280 millions de RMB, projet de collecte de fonds de 1,5 milliard de Beida Pharmaceutical est actionnaire
SCM polling program framework based on linked list management
mac redis安装与使用,连接远程服务器 redis
2022 Shandong Province safety officer C certificate examination question bank and online simulation examination
.Net之延迟队列
奇妙秘境 码蹄集
OPPO Find N2产品形态首曝:补齐各项短板
CVPR 2022 | 大幅减少零样本学习所需的人工标注,提出富含视觉信息的类别语义嵌入(源代码下载)...
Worried about "cutting off gas", Germany is revising the energy security law
吃透Chisel语言.10.Chisel项目构建、运行和测试(二)——Chisel中生成Verilog代码&Chisel开发流程
【Antd踩坑】Antd Form 配合Input.Group时出现Form.Item所占据的高度不对
如何在 2022 年为 Web 应用程序选择技术堆栈
易周金融 | Q1保险行业活跃人数8688.67万人 19家支付机构牌照被注销
嵌入式编程中五个必探的“潜在错误”
源码编译安装MySQL
Go 语言入门很简单:Go 实现凯撒密码
C语言集合运算
Doctoral application | West Lake University Learning and reasoning system laboratory recruits postdoctoral / doctoral / research internship, etc
MongoDB常用28条查询语句(转)