链接:https://www.nowcoder.com/acm/contest/143/G
来源:牛客网
时间限制:C/C++ 1秒,其他语言2秒
空间限制:C/C++ 262144K,其他语言524288K
64bit IO Format: %lld
题目描述
Give two positive integer c, n. You need to find a pair of integer (a,b) satisfy 1<=a,b<=n and the greatest common division of a and b is c.And you need to maximize the product of a and b
输入描述:
The first line has two positive integer c,n
输出描述:
Output the maximum product of a and b. If there are no such a and b, just output -1
示例1
输入
2 4
输出
8
说明
a=2,b=4
备注:
1<=c,n<=10^9
#include<cstdio>
#include<cmath>
#include<cstring>
#include<map>
#include<set>
#include<algorithm>
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#define LL long long
#define ull unsigned long long
#define INF 0x3f3f3f3f
#define PI acos(-1.0)
#define lson o<<1
#define rson o<<1|1
using namespace std;
int main()
{
LL c, n;
cin >> c >> n;
if(c > n)
puts("-1");
else if(n < c * 2)
printf("%lld\n", c * c);
else
printf("%lld\n", (n / c) * c * (n / c - 1) * c);
return 0;
}