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模块 ...
随机推荐
- BZOJ 1006: [HNOI2008]神奇的国度( MCS )
弦图最小染色...先用MCS求出完美消除序列然后再暴力染色... ------------------------------------------------------------------- ...
- Delphi资源大全
A curated list of awesome Delphi frameworks, libraries, resources, and shiny things. Inspired by awe ...
- 【每日一摩斯】-Shared Pool优化和Library Cache Latch冲突优化 (1523934.1)-系列3
减轻Shared Pool负载 Parse一次并执行多次 在OLTP类型的应用中,最好的方法是只让一个语句被解析一次,然后保持这个cursor的打开状态,在需要的时候重复执行它.这样做的 ...
- NOI2015 寿司晚宴
今年NOI确实是在下输了.最近想把当时不会做的题都写一下. 题意 从2到n(500)这些数字中,选若干分给A,若干分给B,满足不存在:A的某个数和B的某个数的GCD不等于1. 对于寿司晚宴这题,标准解 ...
- Duanxx的C++得知:计算位数
一旦计算出一个数值数字,基本上它是不断分裂使用10.重新计,看看有多少个数字. 今天发现能够考虑先将数字转换为字符串,然后通过string.length获得数值的位数,这样做方便的多. string ...
- grep命令參数及使用方法
功能说明:查找文件中符合条件的字符串. 语 法:grep [-abcEFGhHilLnqrsvVwxy][-A<显示列数>][-B<显示列数>][-C<显示列数>] ...
- 关于PhpDE zend ide破解方式
1.文件和汉化文件 ZendStudio官方下载地址:http://www.geekso.com/component/zendstudio-downloads/ 百度云地址: 10.0.0.msi文件 ...
- Windebug双机调试环境搭建
Windebug双机调试环境搭建 开始进行内核编程/驱动编程的调试工作是非常烦人的,由于程序运行与内核层不受操作系统的管控,所以容易引起主机蓝屏和崩溃是常有的事.这也就使得内核程序的调试成了一大 ...
- Mysql事务,并发问题,锁机制-- 幻读、不可重复读(转)
1.什么是事务 事务是一条或多条数据库操作语句的组合,具备ACID,4个特点. 原子性:要不全部成功,要不全部撤销 隔离性:事务之间相互独立,互不干扰 一致性:数据库正确地改变状态后,数据库的一致性约 ...
- cairo graphics.org
cairographics.org Latest news: 2013-08-26: cairo 1.12.16 snapshot available 2013-02-10: cairo 1.12.1 ...