链接:https://ac.nowcoder.com/acm/contest/275/H
来源:牛客网
题目描述
给定 n,求一对整数 (i,j),在满足 1 ≤ i ≤ j ≤ n 且 的前提下,要求最大化 i+j 的值
输入描述:
第一行一个整数 n
输出描述:
一行一个整数表示答案
示例1
输入
复制
2
输出
复制
3
备注:
数据范围 1 ≤ n ≤ 1018
代码:
#include<bits/stdc++.h>
using
namespace
std;
int
main()
{
long
long
a;
cin>>a;
if
(a>1)
{
cout<<a+a-1<<endl;
}
else
cout<<2<<endl;
}
刚开始,想了很多很多;
还有最后一直有Bug,回到题意,才发现,输入为1,输出为2;
两个相邻的数最大公约数为1.