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 ...
随机推荐
- 迷你MVVM框架 avalonjs 学习教程22、avalon性能大揭密
avalon之所以能在页面处理1W个绑定(angular对应的数字是2000),出于两个重要设计--基于事件驱动的双向绑定链及智能CG回收机制. avalon的双向绑定链是通过Object.defin ...
- bash: ifconfig: command not found 问题解决
ifconfig使用出现问题了?竟然提示找不到~~于是百度~~ [flymouse@localhost /]$ ifconfig 提示:“bash: ifconfig: command not fou ...
- fiddler无法抓取chrome解决方法
前端开发中,不可避免的要和服务器端进行联调,少了fiddler这个利器可不行. 由于无线开发需要配置UA,我使用chrome进行访问,但是今儿一早过来,发现fiddler无法抓取chrome的请求了. ...
- k-means处理图片
问题描述:把给定图片,用图片中最主要的三种颜色来表示该图片 k-means思想: 1.选择k个点作为初始中心 2.将每个点指派到最近的中心,形成k个簇cluster 3.重新计算每个簇的中心 4.如果 ...
- Ubuntu 安装 Zabbix 3.2详细步骤
创建 zabbix 用户 因为zabbix 程序的守护进程需要非特权用户,所以需要创建一个 zabbix 用户,即使从 root 用户启动 zabbix 程序,也会自动切换到 zabbix 用户,所以 ...
- Python3 input() 函数
Python3 input() 函数 Python3 内置函数 Python3.x 中 input() 函数接受一个标准输入数据,返回为 string 类型. 注意:在 Python3.x 中 ra ...
- ReportViewer工具栏功能扩展[手动设置打印/导出按钮]
ReportViewer在IE11后打印按钮就存在兼容问题,火狐,谷歌也存在打印按钮显示的兼容性问题,本资料就是解决ReportViewer打印按钮显示的问题, 通过自己写脚本添加到DOM里面让所有浏 ...
- [leetcode]174. Dungeon Game地牢游戏
The demons had captured the princess (P) and imprisoned her in the bottom-right corner of a dungeon. ...
- [leetcode]112. Path Sum路径和(是否有路径)
Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all ...
- [leetcode]139. Word Break单词能否拆分
Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, determine ...