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 Problem
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 230 Accepted Submission(s): 136
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.
For each test cases,the first line contains an integer n.
- #include <iostream>
- #include <string.h>
- #include <stdio.h>
- #include <algorithm>
- #define ll long long
- using 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)的更多相关文章
- 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 ...
- 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 ...
- 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 ...
- 2013 多校联合 2 A Balls Rearrangement (hdu 4611)
Balls Rearrangement Time Limit: 9000/3000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Othe ...
- Contest1585 - 2018-2019赛季多校联合新生训练赛第一场(部分题解)
Contest1585 - 2018-2019赛季多校联合新生训练赛第一场 C 10187 查找特定的合数 D 10188 传话游戏 H 10192 扫雷游戏 C 传送门 题干: 题目描述 自然数中除 ...
- HDU 4690 EBCDIC (2013多校 1005题 胡搞题)
EBCDIC Time Limit: 2000/2000 MS (Java/Others) Memory Limit: 102400/102400 K (Java/Others)Total Su ...
- 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 ...
- HDU 4678 Mine (2013多校8 1003题 博弈)
Mine Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)Total Submis ...
- 2016暑假多校联合---Rikka with Sequence (线段树)
2016暑假多校联合---Rikka with Sequence (线段树) Problem Description As we know, Rikka is poor at math. Yuta i ...
随机推荐
- mysql 内存占用过多的解决方法
以下是5.6默认的设置performance_schema_max_table_instances 12500table_definition_cache 1400table_open_cache 2 ...
- scala-- 内建控制结构
内建控制结构 scala 内建的控制结构很少,只有 if while for try match 和函数调用 几种. 因为scala 从语法层面支持函数字面量.几乎所有的scala控制结构都会产生 ...
- git cherry-pick基本使用
git cherry-pick可以选择某一分支中的一个或几个commit来进行操作--commit 使用场景: 稳定版本分支1与开发版本分支2,不能直接把两个分支合并,否则会导致版本混乱,要将分支2中 ...
- 如何写一个自定义的js文件
自定义一个Utils.js文件,在其中写js代码即可.如: (function(w){ function Utils(){} Utils.prototype.getChilds = function( ...
- JVM7、8详解及优化
一.引言:永久代为什么被移出HotSpot JVM了? 详见:JEP 122: Remove the Permanent Generation 原因主要有两个: 1.由于Permanent Gener ...
- 工作流和过程自动化框架 Camunda BPM
Camunda BPM 是一个灵活的工作流和过程自动化框架,它的核心是一个在Java虚拟机内部运行的原生BPMN 2.0流程引擎,因此它可以嵌入到任何Java应用程序或运行时容器中.Camunda B ...
- golang获取IP地址
ip:=this.Ctx.Request.RemoteAddr ip=ip[0:strings.LastIndex(ip, ":")]
- ECMAScript5新特性之isFrozen、freeze
对象被冻结后: 1 不能添加属性. 2 不能删除属性. 3 不能修改属性.(赋值) 4 不能修改属性描述符.(会抛异常) var fruit = { name : '苹果', desc : '红富士' ...
- jsoncpp在Windows和Linux下的安装
Windows下: 参考这个网站,没什么问题,注意MTd这些选对就行了. http://www.cppblog.com/wanghaiguang/archive/2013/12/26/205020.h ...
- Mac 终端便利工具: 管理工具-Homebrew 和提示工具oh my zsh
命令行提示工具 第一步: Homebrew - 安装与使用 https://blog.csdn.net/sir_coding/article/details/77509602 Homebrew安装问题 ...