The Unsolvable Problem

题目链接:http://acm.hust.edu.cn/vjudge/problem/visitOriginUrl.action?id=45783

题意:

给定一个整数n(2 < = x < = 10^9),我们应该找到一双正整数a,b,满足a + b = n和a,b的最小公倍数是尽可能大;

输出这个最大的最小公倍数。

题目要求要T组案例。

案例:

Sampl Input

3

2

3

4

Sample Output

1

2

3

解题思路:

由于2<=x<=10^9数据太大如果用从1开始一一枚举的方法会超时;

分析会发现a,b越接近x/2,它们的最小公倍数最大。

判断n是奇数还是偶数,如果是奇数就输出x/2*x/2+1,

如果是偶数在进行判断,如果x==2输出1,

如果x/2是偶数输出x/2-1*x/2+1;

否则输出 x/2—2*x/2+2。

 #include<iostream>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
long long x;
cin>>x;
if(x==)
cout<<<<endl;
else if(x%==)
cout<<(x/)*(x/+)<<endl;
else if((x/)%==)
cout<<(x/-)*(x/+)<<endl;
else
cout<<(x/-)*(x/+)<<endl;
}
return ;
}

The Unsolvable Problem的更多相关文章

  1. hdu 4627 The Unsolvable Problem(暴力的搜索)

    Problem Description There are many unsolvable problem in the world.It could be about one or about ze ...

  2. 2013多校联合3 G The Unsolvable Problem(hdu 4627)

    2013-07-30 20:35 388人阅读 评论(0) 收藏 举报 http://acm.hdu.edu.cn/showproblem.php?pid=4627 The Unsolvable Pr ...

  3. hdu 4627 The Unsolvable Problem【hdu2013多校3签到】

    链接: http://acm.hdu.edu.cn/showproblem.php?pid=4627 The Unsolvable Problem Time Limit: 2000/1000 MS ( ...

  4. HDU 4627 There are many unsolvable problem in the world.It could be about one or about zero.But this time it is about bigger number.

    题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=82974#problem/E 解题思路:数论,从一个数的中间开始往两边找,找到两 ...

  5. hdu 4627 The Unsolvable Problem

    http://acm.hdu.edu.cn/showproblem.php?pid=4627 分类讨论一下就可以 代码: #include<iostream> #include<cs ...

  6. HDU 4627 The Unsolvable Problem 2013 Multi-University Training Contest 3

    给你一个数 n ( 2 <= n <= 109 ),现在需要你找到一对数a, b (a + b = n),并且使得LCM(a, b)尽可能的大,然后输出最大的 LCM(a, b). (为什 ...

  7. HDU-4627 The Unsolvable Problem 简单数学

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4627 对n除个2,然后考虑下奇偶... //STATUS:C++_AC_15MS_228KB #inc ...

  8. HDU 4627 The Unsolvable Problem(简单题)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4627 题目大意:给定一个整数n(2 <= n <= 109),满足a+b=n并且[a,b] ...

  9. HDU 4627 The Unsolvable Problem 杭电多校联赛第三场1009 数学题

    题意描述:给出一个n,要求在所有满足n = a+b的a和b里面求a和b的最小公倍数最大的两个数的最小公倍数. 解题报告:比赛的时候看到这个题的第一反应就是寻找这两个数一定是在a和b比较接近的地方找,这 ...

随机推荐

  1. Accelerating Matlab

    Matlab is a very useful programming environment, but it also has many inefficiencies. You might thin ...

  2. 如何设计一个优秀的API(转)

    到目前为止,已经负责API接近两年了,这两年中发现现有的API存在的问题越来越多,但很多API一旦发布后就不再能修改了,即时升级和维护是必须的.一旦API发生变化,就可能对相关的调用者带来巨大的代价, ...

  3. Android 大牛的 blog 值得推荐 (转 整理)

    1 收集了 国外著名开发者 25 人,包括 Github 地址.Blog 地址以及重点贡献介绍 链接 收集了 国内部分开发者 32人,包括 Github 地址.Blog 地址以及重点贡献介绍, 链接 ...

  4. JQuery经典小例子——可编辑的表格

    可编辑的表格: 屏幕剪辑的捕获时间: 2015/8/14 9:16 HTML代码为: <!DOCTYPE html> <htmlxmlns="http://www.w3.o ...

  5. SpringRMI解析3-RmiServiceExporter逻辑细节

    在发布RMI服务的流程中,有几个步骤可能是我们比较关心的. 获取registry 由于底层的封装,获取Registry实例是非常简单的,只需要使用一个函数LocateRegistry.createRe ...

  6. hdu4968

    题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=4968 说是考dp,但是我没出来dp在哪,可能贪心思想更多一些吧. AC代码: #inclu ...

  7. css布局1

    body <body> <header id='title'> <h1>Holla</h1> </header> <div id='c ...

  8. POJ1201 Intervals差分约束系统(最短路)

    Description You are given n closed, integer intervals [ai, bi] and n integers c1, ..., cn. Write a p ...

  9. 【面经】用递归方法对二叉树进行层次遍历 && 二叉树深度

    void PrintNodeAtLevel(BiTree T,int level) { // 空树或层级不合理 ) return; == level) { cout << T->da ...

  10. NSDICTIONARY获取内容的CRASH

    NSString *path = [self.dataPath stringByAppendingPathComponent:@"dummy.plist"]; NSMutableD ...