链接:


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. Python——在Unicode和普通字符串之间转换

    1.1. 问题 Problem You need to deal with data that doesn't fit in the ASCII character set. 你需要处理不适合用ASC ...

  2. Python基础之字符串的练习

    练习1 #!/usr/bin/python -tt # Copyright 2010 Google Inc. # Licensed under the Apache License, Version ...

  3. 由于删除DBF文件报错 —— ORA-01033: ORACLE initialization or shutdown in progress

    由于移动或删除DBF文件报错:ORA-01033: ORACLE initialization or shutdown in progress   原因:一般该类故障通常是由于移动文件而影响了数据库日 ...

  4. Quartz.net基于数据库的任务调度管理(Only.Jobs)

    一 前言: 各大调度组件优缺点在这就不讨论了,使用Quartz.net是因为它可以执行秒级任务. Only.Jobs 项目通过将各Job存储在数据库中,启动一个专门的Job管理任务来循环调度各Job的 ...

  5. .NET下的ORM框架有哪些

    现在市面上针对.NET ORM框架越来越多 微软自家的LINQ to SQL, ADO.NET Entity Framework不多说. 商业: 1.LightSpeed(免费版比较垃圾.表限制8个. ...

  6. Python - pandas 数据分析

    pandas: powerful Python data analysis toolkit 官方文档: http://pandas.pydata.org/pandas-docs/stable/ 1. ...

  7. 今日头条&58转转笔试

    昨天参加今日头条和58转转的笔试,因为时间上有冲突,所以主要选择参加头条的笔试. 先说头条: 头条的题型: 一道改错题 三道编程题 一道设计题 感受: 做题目的的时候还是有点紧张的,因为突然遇到题目需 ...

  8. Nginx 0.8.x + PHP 5.2.13(FastCGI)搭建胜过Apache十倍的Web服务器(第6版)(转)

    转自:http://blog.s135.com/nginx_php_v6/] 前言:本文是我撰写的关于搭建“Nginx + PHP(FastCGI)”Web服务器的第6篇文章.本系列文章作为国内最早详 ...

  9. DMA (直接存储器访问)

    DMA (直接存储器访问) 编辑 DMA(Direct Memory Access,直接内存存取) 是所有现代电脑的重要特色,它允许不同速度的硬件装置来沟通,而不需要依赖于 CPU 的大量中断负载.否 ...

  10. JAVA 利用SimpleDateFormat将String转换为格式化的日期

    1. /** * 使用用户格式提取字符串日期 * * @param strDate 日期字符串 * @param pattern 日期格式 * @return */ public static Dat ...