链接:


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. LInux——安装Apache

    在安装Apache的httpd的时候经常会遇到: configure: error: APR not found .  Please read the documentation. configure ...

  2. android-数据库SQLite相关

    android平台下的SQLite数据库是一种轻量级数据库,支持标准的SQL语句. 本文将介绍 android数据库的创建 利用sql语句对数据库增删改查 系统api数据库增删改查 数据库的事务 1, ...

  3. Log4j介绍,log4j.properties配置详解

    http://www.cnblogs.com/simle/archive/2011/09/29/2195341.html本文主要解释log4j的配置文件各个配置项的含义,内容是从网上转载的 1.Log ...

  4. JavaScript在IE浏览器和Firefox浏览器中的差异总结

    JavaScript在IE浏览器和Firefox浏览器中存在一些差异,以下对这些差异部分进行了总结,以及解决方案: 1.HTML对象的 id 作为对象名的问题 IE:HTML 对象的 ID 可以作为 ...

  5. 关于jQuery库的引用

    2018-08-06 10:28:38 1. 经过几次试坑,发现最简便的方法就是直接在官网上下载  jQuery文件 . 2. 官网上有两个下载版本,一个是经过压缩的(用于发布),一个是没有经过压缩的 ...

  6. linux后台运行命令

    Ctrl+z/bg/nohup/setsid/& screen 区别待续

  7. Closure闭包示例

    var foo = function(){ var cnt = 0; return function(){ return cnt++; }; }; var closure = foo(); conso ...

  8. zookeeper 批量启动的脚本

    #!/bin/shecho "start zkServer"for i in  2 3 4dossh mini$i "source /etc/profile;/usr/l ...

  9. tcpreplay工具安装使用

    一.Tcpreplay功能简介 首先推荐一个网站:http://tcpreplay.synfin.net/ ,上面有Tcpreplay的安装包和很多文档,包括手册.man页和FAQ等. Tcprepl ...

  10. OpenCV中的SURF算法介绍

    SURF:speed up robust feature,翻译为快速鲁棒特征.首先就其中涉及到的特征点和描述符做一些简单的介绍: 特征点和描述符 特征点分为两类:狭义特征点和广义特征点.狭义特征点的位 ...