链接:


The Unsolvable Problem

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)

Total Submission(s): 243    Accepted Submission(s): 143

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

Given an integer n(2 <= n <= 109).We should find a pair of positive integer a, b so that a + b = n and [a, b] is as large as possible. [a, b] denote the least common multiplier of a, b.
 
Input
The first line contains integer T(1<= T<= 10000),denote the number of the test cases.

For each test cases,the first line contains an integer n.
 
Output
For each test cases,print the maximum [a,b] in a line.
 
Sample Input
3
2
3
4
 
Sample Output
1
2
3
 
Source
 


题意:

               找最大的最小公倍数
            给你一个数 N , a+b = N ,找最大的 lcm(a,b)

思路:

           奇数的随便就看出来了,取一半就好了
        偶数的,写个暴力程序,打下表也可以随便看出规律,取一半了
#include<stdio.h>
#include<math.h>
#include<algorithm>
using namespace std; __int64 gcd(__int64 a, __int64 b)
{
return b == 0 ? a : gcd(b,a%b);
} __int64 lcm(__int64 a, __int64 b){
return a/gcd(a,b)*b;
} int main()
{
int T;
__int64 n;
scanf("%d", &T);
while(T--)
{
scanf("%I64d", &n);
__int64 a,b;
__int64 ans = 0,tmp1,tmp2;
if(n&1) ans = lcm(n/2,n/2+1);
else
{
if(n == 2) ans = 1;
else
{
__int64 c = n/2-1;
tmp1 = lcm(c,n-c);
tmp2 = lcm(c-1,(n-c+1));
ans = max(tmp1,tmp2);
}
}
printf("%I64d\n", ans);
}
return 0;
}

 

hdu 4627 The Unsolvable Problem【hdu2013多校3签到】的更多相关文章

  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. HDU 4627 The Unsolvable Problem 杭电多校联赛第三场1009 数学题

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

  3. hdu 4627 The Unsolvable Problem

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

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

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

  5. 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). (为什 ...

  6. HDU 5402 Travelling Salesman Problem(多校9 模拟)

    题目链接:pid=5402">http://acm.hdu.edu.cn/showproblem.php?pid=5402 题意:给出一个n×m的矩阵,位置(i.j)有一个非负权值. ...

  7. 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 ...

  8. HDU 4627(最小公倍数最大问题)

    HDU 4627 Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u   Descript ...

  9. The Unsolvable Problem

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

随机推荐

  1. NSight统计数据的颜色,缩写意义是什么?来自NV Jeff Kiel 比较官方的解释!

    结合这个图示来看:https://dl.dropboxusercontent.com/u/32077444/nsight.pdf 1) The bars you see in the Summary ...

  2. 常用sql语句记录

    1.表 --建表 if OBJECT_ID('Student') is not null create table Student( ID ,) not null, Name ), Code ), f ...

  3. PHP经常使用正則表達式汇总

    1.    平时做站点常常要用正則表達式,以下是一些解说和样例,仅供大家參考和改动使用:  2.    "^\d+$" //非负整数(正整数 + 0)  3.    "^ ...

  4. Linux 下 grep 命令常用方法简介

    1.从单个文件中搜索指定的字符串: $ grep "literal-string" filename 该命令会输出字符串在文件中所在行的内容,如果字符串没有空格,则可以不加双引号. ...

  5. angular4 radio checkbox 有用

    <span *ngFor="let op of [{'id':'a','text':'11'},{'id':'b','text':'2222'},{'id':'cc','text':' ...

  6. PHP 7安装使用体验,升级PHP要谨慎

    一.发挥PHP 7高性能的几个要点 PHP 7相对于之前的PHP版本来说可以说性能有了质的飞跃,但是所谓“好马配好鞍,好车配风帆”,想要发挥PHP 7的性能优势,还需要从以下几个方面做准备:(此部分引 ...

  7. Unity3D - 使用TexturePacker打包图集以及NGUI对旋转sprites的支持

    作者:EnigmaJJ 博客地址:http://www.cnblogs.com/twjcnblog/ 在Unity中使用NGUI时,为了减少draw call,我们会将美术用到的小图打成一张图集,如图 ...

  8. html 标签 图片

    <img src="e:/image/a.png"/> 在html中,图片是一个字符. <img src=" e:/image/a.png" ...

  9. Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed

    错误原因:常量.随机或者依赖时区的表达式不能作为分区函数. 解决方法:把ts列换成datetime类型,创建成功. CREATE TABLE T_log( id INT(11) NOT NULL AU ...

  10. linux rz xshell

    这个命令写好好几次 就是没有记住 放到这里 每次用的时候查一遍 慢慢就记住了~~~ sudo yum install lrzsz -y