the least common multiplier
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>
using namespace std;
int gcd(int a,int b){
int c=b%a;
while(c>){
b=a;
a=c;
c=b%a;
}
return a;
} int main()
{
int t;cin>>t;int n;
while(t--){
__int64 sum=,i;
cin>>n;
for(i=n/;i>;i--){
if(gcd(i,n-i)==)
{
sum=i*(n-i);
break;
}
}
cout<<sum<<endl;
}
return ;
}
the least common multiplier的更多相关文章
- HDU 4627 E(Contest #3)
Description There are many unsolvable problem in the world.It could be about one or about zero.But t ...
- HDU/杭电2013多校第三场解题报告
今天悲剧了,各种被虐啊,还是太年轻了 Crime 这道题目给的时间好长,第一次就想到了暴力,结果华丽丽的TLE了. 后来找了一下,发现前24个是1, 2, 6, 12, 72, 72, 864, 17 ...
- HDU 4627(最小公倍数最大问题)
HDU 4627 Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Descript ...
- hdu 4627 The Unsolvable Problem(暴力的搜索)
Problem Description There are many unsolvable problem in the world.It could be about one or about ze ...
- 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 The Unsolvable Problem【hdu2013多校3签到】
链接: http://acm.hdu.edu.cn/showproblem.php?pid=4627 The Unsolvable Problem Time Limit: 2000/1000 MS ( ...
- Appendix A. Common application properties
Appendix A. Common application properties Prev Part X. Appendices Next URl链接:https://docs.spring.i ...
- Spring Boot Common application properties(转载)
转自官方文档:http://docs.spring.io/spring-boot/docs/current/reference/html/common-application-properties.h ...
- Socket聊天程序——Common
写在前面: 上一篇记录了Socket聊天程序的客户端设计,为了记录的完整性,这里还是将Socket聊天的最后一个模块--Common模块记录一下.Common的设计如下: 功能说明: Common模块 ...
随机推荐
- C#学习之-----再论委托
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threa ...
- BZOJ 3132: 上帝造题的七分钟( 二维BIT )
二维树状数组... 自己YY一下再推一下应该可以搞出来... --------------------------------------------------------------------- ...
- 4.I/O复用以及基于I/O复用的回射客户端/服务器
I/O复用:当一个或多个I/O条件满足时,我们就被通知到,这种能力被称为I/O复用. 1.I/O复用的相关系统调用 posix的实现提供了select.poll.epoll两类系统调用以及相关的函数来 ...
- Week2(9月19日):增加一个CodeFirst的例子来说明
Part I:提问 =========================== 1.上堂课中我们使用了()数据库,它是()可部署的,只需要将相应的()文件添加到应用程序的()文件夹,就可以使用了,该数据 ...
- Week5(10月10日):国庆之后,让我们整装期待元旦吧
Part I:提问 =========================== 1.要将“Hello, Admin",从控制器传递到视图,该如何操作? (1)使用ViewData (2)使用V ...
- 转:Bootstrap研究 精巧的网格布局系统
本网格布局系统属于Scaffolding(框架,布局)部分.在Scaffolding里面有(固定)网格布局(Grid System)和流式网格布局(Fluid Grid System).本文讨论第一种 ...
- Tri_integral Summer Training 8 总结
比赛链接 题目 B C E F G I 这是孟加拉国的区域赛. 开场ss读懂了c发现是个水题,于是去敲,结果手贱wa了一炮,不过很快就修正了错误.B题过了不少,我去读,发现是个水题,意识让Moor敲. ...
- Axis2(9):编写Axis2模块(Module)
Axis2可以通过模块(Module)进行扩展.Axis2模块至少需要有两个类,这两个类分别实现了Module和Handler接口.开发和使用一个Axis2模块的步骤如下: 1. 编写实现Module ...
- Aizu 1335 Eequal sum sets
Let us consider sets of positive integers less than or equal to n. Note that all elements of a set a ...
- SuperSocket源码解析之消息处理
一 简述 Tcp消息的处理本身是与Tcp消息传输过程独立的,是消息的两个不同阶段,从前面的会话生命周期我们已经知道消息的传输主要有SocketSession实现,而真正处理则交由AppSession实 ...