博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
the least common multiplier
阅读量:4449 次
发布时间:2019-06-07

本文共 1062 字,大约阅读时间需要 3 分钟。

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 <= 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

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
 
#include 
using namespace std;int gcd(int a,int b){ int c=b%a; while(c>0){ b=a; a=c; c=b%a; }return a;}int main(){ int t;cin>>t;int n; while(t--){ __int64 sum=0,i; cin>>n; for(i=n/2;i>0;i--){ if(gcd(i,n-i)==1) { sum=i*(n-i); break; } } cout<
<
View Code

 

转载于:https://www.cnblogs.com/demodemo/p/4655719.html

你可能感兴趣的文章
Java50道经典习题-程序31 数组逆序
查看>>
5.28 考试修改+总结
查看>>
oracle 数据库事务,提交,回滚,保存点,表的锁定,隐式锁,显示锁,写锁,读锁,排他锁,共享锁...
查看>>
vscode同步设置&扩展插件
查看>>
tomcat部署web项目的方式 转
查看>>
js中,for循环里面放ajax,ajax访问不到变量以及每次循环获取不到数据问题总结...
查看>>
算法:求从1到n这n个整数的十进制表示中1出现的次数-- python 实现
查看>>
CSU 1160 把十进制整数转换为十六进制,格式为0x开头,10~15由大写字母A~F表示
查看>>
LintCode 58: Compare Strings
查看>>
[Unity插件]Lua行为树(五):装饰节点Repeater
查看>>
限制.svn 访问
查看>>
从lca到树链剖分 bestcoder round#45 1003
查看>>
顺序表、链表、栈和队列
查看>>
Linux第二天(Linux常用命令2)
查看>>
MySql知识体系
查看>>
JIRA中的标记语言的语法参考
查看>>
hdu 6318 Swaps and Inversions(归并排序)
查看>>
用css在IE7、8上实现圆角
查看>>
三维绿幕标定与跟踪
查看>>
android ProgressBar自定义半圆形进度条
查看>>