链接:


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. Web service--百度百科

    Web service是一个平台独立的,低耦合的,自包含的.基于可编程的web的应用程序,可使用开放的XML(标准通用标记语言下的一个子集)标准来描述.发布.发现.协调和配置这些应用程序,用于开发分布 ...

  2. Ubuntu git 安装、生成sshkey、克隆、切换分支

    #1.安装git apt-get install git; #2生成公钥私钥文件 2.配置git账户: git config --global user.name "yourname&quo ...

  3. (二)Linux——Linux常用指令

    1. 文件目录操作命令 ls 显示文件和目录列表     -l 列出文件的详细信息 -a 列出当前目录所有文件,包含隐藏文件 mkdir 创建目录 -p 父目录不存在情况下先生成父目录 cd 切换目录 ...

  4. 安装Drupal7.12+Postgresql9.1(Ubuntu Server 12.04)

    怀揣着为中小企业量身定做一整套开源软件解决方案的梦想开始了一个网站的搭建.http://osssme.org/ OS环境准备 这次是从OS开始安装的.最开始装Ubuntu12.04这里就不再赘述, 唯 ...

  5. [原创]FreeSWITCH实现多人来电思路

    [原创]FreeSWITCH实现多人来电思路 场景介绍 该篇文章主要用于介绍如何使用FreeSWITCH实现通讯系统中常见的多人来电功能. 具体场景如下: A与B正在通话中,此时C拨打A/B,Free ...

  6. SVN checkout 功能不可用 右键只看到提交和更新,没有显示checkout

    不要在受SVN控制的文件夹里点右键,因为这个文件夹已经在SVN控制之下,当然不会允许在里面嵌套另一个SVN版本库换个不受控的文件夹点右键,比如D盘根目录

  7. js将用户上传gif动图分解成多张帧图片

    js将用户上传gif动图分解成多张帧图片 写在前面 工作中遇到一个这么一个需求:这是一个多图上传的场景,如果用户上传选择多张图片,则上传后直接展示多张图片,如果上传的图片是gif动图,则需要分解这张动 ...

  8. Linux操作系统下/etc/hosts文件配置方法

    1.关于/etc/host,主机名和IP配置文件 Hosts - The static table lookup for host name(主机名查询静态表) hosts文件是Linux系统中一个负 ...

  9. PILE读书笔记_文件I/O

    open函数 int open(const char *pathname, int flags, mode_t mode); 参数说明: (1)pathname: 表示要打开的文件路径 (2)flag ...

  10. linux下调试使用的 一些shell命令

    查看文件日期:strings |grep Build gdb g++ gcc make systemctl gdb: bt s n b 1.firewalld的基本使用 启动: systemctl s ...