当前位置:网站首页>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;
}
边栏推荐
- 美国土安全部长:国内暴力极端主义是目前美面临的最大恐怖主义威胁之一
- C语言程序设计选题参考
- 吃透Chisel语言.12.Chisel项目构建、运行和测试(四)——Chisel测试之ChiselTest
- MongoDB常用28条查询语句(转)
- Yingshi Ruida rushes to the scientific and Technological Innovation Board: the annual revenue is 450million and the proposed fund-raising is 979million
- C language staff management system
- 基于链表管理的单片机轮询程序框架
- 2022年起重机械指挥考试模拟100题模拟考试平台操作
- Programmer anxiety
- 吃透Chisel语言.11.Chisel项目构建、运行和测试(三)——Chisel测试之ScalaTest
猜你喜欢
SCM polling program framework based on linked list management
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
CVPR 2022 | 大幅减少零样本学习所需的人工标注,提出富含视觉信息的类别语义嵌入(源代码下载)...
嵌入式编程中五个必探的“潜在错误”
Fisher信息量检测对抗样本代码详解
Summary of recent days (non-technical article)
Distributed base theory
安装Mysql
博士申请 | 西湖大学学习与推理系统实验室招收博后/博士/研究实习等
德明利深交所上市:市值31亿 为李虎与田华夫妻档
随机推荐
Getting started with the go language is simple: go implements the Caesar password
2022危险化学品经营单位主要负责人练习题及模拟考试
中邮科技冲刺科创板:年营收20.58亿 邮政集团是大股东
动画与过渡效果
1200. Minimum absolute difference
2022G3锅炉水处理考试题模拟考试题库及模拟考试
2022kdd pre lecture | 11 first-class scholars take you to unlock excellent papers in advance
OPPO Find N2产品形态首曝:补齐各项短板
MySQL8版本免安装步骤教程
C语言集合运算
吃透Chisel语言.04.Chisel基础(一)——信号类型和常量
C语言程序设计选题参考
go vendor 项目迁移到 mod 项目
go语言中的文件创建,写入,读取,删除(转)
One of the solutions for unity not recognizing riders
Read excel table data
使用默认路由作为指向Internet的路由
Go 语言入门很简单:Go 实现凯撒密码
sharding key type not supported
【Antd】Antd 如何在 Form.Item 中有 Input.Gourp 时获取 Input.Gourp 的每一个 Input 的value