HDU 4627 E(Contest #3)
Description
Given an integer n(2 <= n <= 10 9).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
For each test cases,the first line contains an integer n.
Output
Sample Input
2
3
4
Sample Output
2
3
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
int t,n;
cin>>t;
while(t--)
{
cin>>n;
if(n==2)
{
cout<<"1"<<endl;
continue;
}
int k=n/2;
if(n%2==1)
printf("%I64d\n",(__int64)k*(k+1));
else
{
if(k%2==1)
printf("%I64d\n",(__int64)(k-2)*(k+2));
else
printf("%I64d\n",(__int64)(k-1)*(k+1));
}
}
return 0;
}
HDU 4627 E(Contest #3)的更多相关文章
- HDU 4627(最小公倍数最大问题)
HDU 4627 Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Descript ...
- 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). (为什 ...
- hdu 4627 The Unsolvable Problem【hdu2013多校3签到】
链接: http://acm.hdu.edu.cn/showproblem.php?pid=4627 The Unsolvable Problem Time Limit: 2000/1000 MS ( ...
- hdu 4627 The Unsolvable Problem
http://acm.hdu.edu.cn/showproblem.php?pid=4627 分类讨论一下就可以 代码: #include<iostream> #include<cs ...
- HDU 4627 The Unsolvable Problem(简单题)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4627 题目大意:给定一个整数n(2 <= n <= 109),满足a+b=n并且[a,b] ...
- HDU 5988.Coding Contest 最小费用最大流
Coding Contest Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)To ...
- 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 ...
- 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 解题思路:数论,从一个数的中间开始往两边找,找到两 ...
- hdu 4627 The Unsolvable Problem(暴力的搜索)
Problem Description There are many unsolvable problem in the world.It could be about one or about ze ...
随机推荐
- Java集合的Stack、Queue、Map的遍历
Java集合的Stack.Queue.Map的遍历 在集合操作中,常常离不开对集合的遍历,对集合遍历一般来说一个foreach就搞定了,但是,对于Stack.Queue.Map类型的遍历,还是有一 ...
- Node 写文件
在程序开发过程中会遇到很多自己认为是对的但实际运行出来并不是自己想的那样的,这个时候就可以把程序运行的比较关键点用文件的方式存储下来,然后分析 node 方式 var fs = require('fs ...
- lx:这么空!什么叫假大空 xy:那我做给你看
“如果我答应你,你回来了XY,最后没有在一起肯定会怪我:而且我现在没有想好以后会怎么样” 希望你可以看到我的努力!PS : 坚持以后每日至少一篇.编程是一门手艺,手艺人靠手艺养家! ---手艺人
- linux mount命令的用法详细解析
挂接命令(mount)首先,介绍一下挂接(mount)命令的使用方法,mount命令参数非常多,这里主要讲一下今天我们要用到的.命令格式:mount [-t vfstype] [-o options] ...
- SQL Server常见基础操作
1. 常见针对表的操作(增删改查) --1. Create Table USE [MVC_000] CREATE TABLE T_TableName ( ID ,) PRIMARY KEY, Name ...
- mysql命令行登录指定编码
mysql --default-character-set=utf8 -uroot -p mysql --default-character-set-utf8 -uroot-p
- 删除内容并不能删除field structure -- features_revert
把内容删了但field structure还在, 在manage_field界面,field还在.http://drupal.stackexchange.com/questions/21501/rev ...
- 3.3 使用Code First数据库迁移
当Entity Framework Code First的数据模型发生异动时,默认会引发一个System.InvalidOpertaionException异常.一种解决方法是在Global.asax ...
- ArcMap中"开始编辑"遇到一个或多个带有警告的图层“如果继续,可能无法编辑某些图层”的警告框
开始编辑后可能出现的错误: 如果 ArcMap 在所选数据上启动编辑会话时遇到问题,将弹出一个对话框以提供附加信息.您可能会收到错误.警告或信息消息. 出现错误 时用户不可以启动任何编辑会话.只有解 ...
- VBA提高速度的技巧
此贴原转自EH论坛,我自己有所修改 [编者按]速度是程序设计永恒的热门话题,虽然速度技巧在各种语言之间可以相互借鉴,但差别有时也会很大,比如VC中由于字符串的存储方式决定了判断空串使用len函数更快, ...