2013多校联合3 G The Unsolvable Problem(hdu 4627)
来源:互联网 发布:淘宝美工教程在线视频 编辑:程序博客网 时间:2024/06/05 06:44
http://acm.hdu.edu.cn/showproblem.php?pid=4627
The Unsolvable Problem
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 230 Accepted Submission(s): 136
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.
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.
For each test cases,the first line contains an integer n.
Output
For each test cases,print the maximum [a,b] in a line.
标准签到题,先特判n==2的情况,否则若n为奇数,则答案显然是n/2 和 n/2+1,若n为偶数设n=2*k,若k为偶数,则答案为k-1,k+1,否则答案为k-2,k+2。
#include <iostream>#include <string.h>#include <stdio.h>#include <algorithm>#define ll long longusing namespace std;int main(){ //freopen("dd.txt","r",stdin); ll n,ncase; cin>>ncase; while(ncase--) { cin>>n; if(n==2) cout<<1<<endl; else { if(n%2) cout<<(n/2)*(n-n/2)<<endl; else { if((n/2)%2==0) cout<<(n/2-1)*(n/2+1)<<endl; else cout<<(n/2-2)*(n/2+2)<<endl; } } } return 0;}
- 2013多校联合3 G The Unsolvable Problem(hdu 4627)
- hdu 4627 The Unsolvable Problem(暴力)
- hdu 4627 The Unsolvable Problem 多校第三场
- hdu - 4627 - The Unsolvable Problem
- HDU-4627-The Unsolvable Problem
- hdu 4627 The Unsolvable Problem
- HDU 4627 The Unsolvable Problem
- 2013 Multi-University Training Contest 3 (g) The Unsolvable Problem
- hdu 4627 The Unsolvable Problem【hdu2013多校3签到】
- HDU 4627 The Unsolvable Problem 解题报告
- hdu 4627 The Unsolvable Problem (数论)
- HDU 4627 The Unsolvable Problem 数学
- HDU 4267 The Unsolvable Problem
- HDU 4691 The Unsolvable Problem 后缀数组
- HDOJ 4627 - The Unsolvable Problem 打表观察..
- 2013暑期多校联合训练\第三场\Problem G
- BUCT OJ 2264: The Unsolvable Problem
- hdu 5373 The shortest problem 2015多校联合训练赛#7 模拟
- MyEclipse中安装SVN插件
- libpcap BSD Packet Filter(BPF)
- Cocos2d-x-2.1.4之Android工程创建及编译
- POJ 1269 Intersecting Lines 判断直线间的状态(平行、重合、相交于一点)
- 数字图像处理:4.色彩空间转换
- 2013多校联合3 G The Unsolvable Problem(hdu 4627)
- 多线程环境下OTL的使用
- 21-函数的递归调用的理解
- 【原】IOS中KVO模式的解析与应用
- js拖动缩放
- struts标签 if 判断的包含用法 indexOf方法
- ubuntu下svn使用指南
- 文件/目录权限设置命令:chmod
- POJ 2449 A* K短路