当前位置:网站首页>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;
}
边栏推荐
- 锐成芯微冲刺科创板:年营收3.67亿拟募资13亿 大唐电信是股东
- [antd step pit] antd form cooperates with input Form The height occupied by item is incorrect
- 使用默认路由作为指向Internet的路由
- 硬件基础知识-二极管基础
- . Net delay queue
- markdown 语法之字体标红
- 【Matlab】conv、filter、conv2、filter2和imfilter卷积函数总结
- Unity Shader学习(三)试着绘制一个圆
- 吃透Chisel语言.11.Chisel项目构建、运行和测试(三)——Chisel测试之ScalaTest
- find命令报错: paths must precede expression(转)
猜你喜欢

好博医疗冲刺科创板:年营收2.6亿 万永钢和沈智群为实控人

Flet tutorial 03 basic introduction to filledbutton (tutorial includes source code) (tutorial includes source code)

392. Judgement subsequence

锐成芯微冲刺科创板:年营收3.67亿拟募资13亿 大唐电信是股东

CVPR 2022 | 大幅减少零样本学习所需的人工标注,提出富含视觉信息的类别语义嵌入(源代码下载)...

Install Trinity and solve error reporting

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

Redis - how to install redis and configuration (how to quickly install redis on ubuntu18.04 and centos7.6 Linux systems)

小程序直播 + 电商,想做新零售电商就用它吧!

免费、好用、强大的轻量级笔记软件评测:Drafts、Apple 备忘录、Flomo、Keep、FlowUs、Agenda、SideNote、Workflowy
随机推荐
美国土安全部部长警告移民“不要踏上危险的旅程”
吃透Chisel语言.10.Chisel项目构建、运行和测试(二)——Chisel中生成Verilog代码&Chisel开发流程
【FAQ】华为帐号服务报错 907135701的常见原因总结和解决方法
MySQL 5 installation and modification free
MongoDB常用28条查询语句(转)
Service Mesh的基本模式
Fs7867s is a voltage detection chip used for power supply voltage monitoring of digital system
Ws2811 m is a special circuit for three channel LED drive and control, and the development of color light strip scheme
China Post technology rushes to the scientific innovation board: the annual revenue is 2.058 billion, and the postal group is the major shareholder
基于链表管理的单片机轮询程序框架
Animation and transition effects
Worried about "cutting off gas", Germany is revising the energy security law
30: Chapter 3: develop Passport Service: 13: develop [change / improve user information, interface]; (use * * * Bo class to accept parameters, and use parameter verification)
德明利深交所上市:市值31亿 为李虎与田华夫妻档
WS2811 M是三通道LED驱动控制专用电路彩灯带方案开发
Introduction to reverse debugging PE structure resource table 07/07
近日小结(非技术文)
SCM polling program framework based on linked list management
C语言集合运算
忠诚协议是否具有法律效力