2013-07-30 20:35 388人阅读 评论(0) 收藏 举报

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.
 
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.
标准签到题,先特判n==2的情况,否则若n为奇数,则答案显然是n/2 和 n/2+1,若n为偶数设n=2*k,若k为偶数,则答案为k-1,k+1,否则答案为k-2,k+2。
    1. #include <iostream>
    2. #include <string.h>
    3. #include <stdio.h>
    4. #include <algorithm>
    5. #define ll long long
    6. using namespace std;
    7. int main()
    8. {
    9. //freopen("dd.txt","r",stdin);
    10. ll n,ncase;
    11. cin>>ncase;
    12. while(ncase--)
    13. {
    14. cin>>n;
    15. if(n==2)
    16. cout<<1<<endl;
    17. else
    18. {
    19. if(n%2)
    20. cout<<(n/2)*(n-n/2)<<endl;
    21. else
    22. {
    23. if((n/2)%2==0)
    24. cout<<(n/2-1)*(n/2+1)<<endl;
    25. else
    26. cout<<(n/2-2)*(n/2+2)<<endl;
    27. }
    28. }
    29. }
    30. return 0;
    31. }
    32. 一开始用暴力,唉,挂了,但是为什么是这样呢,想了半天终于明白了。

2013多校联合3 G The Unsolvable Problem(hdu 4627)的更多相关文章

  1. 2013 多校联合 F Magic Ball Game (hdu 4605)

    http://acm.hdu.edu.cn/showproblem.php?pid=4605 Magic Ball Game Time Limit: 10000/5000 MS (Java/Other ...

  2. 2013多校联合2 I Warm up 2(hdu 4619)

    Warm up 2 Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others) Total ...

  3. 2013 多校联合2 D Vases and Flowers (hdu 4614)

    Vases and Flowers Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others ...

  4. 2013 多校联合 2 A Balls Rearrangement (hdu 4611)

    Balls Rearrangement Time Limit: 9000/3000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Othe ...

  5. Contest1585 - 2018-2019赛季多校联合新生训练赛第一场(部分题解)

    Contest1585 - 2018-2019赛季多校联合新生训练赛第一场 C 10187 查找特定的合数 D 10188 传话游戏 H 10192 扫雷游戏 C 传送门 题干: 题目描述 自然数中除 ...

  6. HDU 4690 EBCDIC (2013多校 1005题 胡搞题)

    EBCDIC Time Limit: 2000/2000 MS (Java/Others)    Memory Limit: 102400/102400 K (Java/Others)Total Su ...

  7. HDU 4685 Prince and Princess (2013多校8 1010题 二分匹配+强连通)

    Prince and Princess Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Othe ...

  8. HDU 4678 Mine (2013多校8 1003题 博弈)

    Mine Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)Total Submis ...

  9. 2016暑假多校联合---Rikka with Sequence (线段树)

    2016暑假多校联合---Rikka with Sequence (线段树) Problem Description As we know, Rikka is poor at math. Yuta i ...

随机推荐

  1. How to Pronounce INTERNATIONAL

    How to Pronounce INTERNATIONAL Share Tweet Share Tagged With: Dropped T How do you pronounce this lo ...

  2. python 日期格式

    %a 星期几的简写%A 星期几的全称%b 月分的简写%B 月份的全称%c 标准的日期的时间串%C 年份的后两位数字%d 十进制表示的每月的第几天%D 月/天/年%e 在两字符域中,十进制表示的每月的第 ...

  3. JSP复习(part 2 )

    3.4.2 访问(获取)请求参数 1.方法 String 字符串变量 =request.getParameter("客户端提供参数的name属性名"): 2.传参数的三种形式 (1 ...

  4. 导出 java.io.IOException: 权限不够

    项目原先都是开发使用root账号登陆服务器,人肉部署. 今天改成了自动部署,部署之后发现导出用不了了,查看服务器日志提示: 查看项目启动用户是app,推断是app用户的权限不够,导致导出无法在服务器创 ...

  5. Gviz

    1) Introduction 为了理解基因组数据,通常旨在在基因组浏览器中绘制这样的数据,以及各种基因组注释特征,例如基因或转录物模型,CpG岛,重复区域等.这些功能可以从ENSEMBL或UCSC等 ...

  6. 判断UNITY版本号

    代码示例: #if (UNITY_5_3 || UNITY_5_4 || UNITY_5_5 || UNITY_5_6 || UNITY_5_7 || UNITY_5_8 || UNITY_5_9)u ...

  7. swift 官方文档

    swift 官方文档 https://swift.org/blog/

  8. javascript正则表达式验证密码(必须含数字字符特殊符号,长度4-16位之间)

    var newpwd = $("#newpassword").val(); //var pattern = "([A-Za-z]|[0-9]|-|_){4,16}&quo ...

  9. mysql 版本bug

    mysql命令gruop by报错this is incompatible with sql_mode=only_full_group_by 在mysql 工具 搜索或者插入数据时报下面错误: ERR ...

  10. db2 查看表空间使用率

    1. 统计所有节点表空间使用率 select substr(TABLESPACE_NAME,1,20) as TBSPC_NAME,bigint(TOTAL_PAGES * PAGE_SIZE)/10 ...