HDU 4627 The Unsolvable Problem 2013 Multi-University Training Contest 3
给你一个数 n ( 2 <= n <= 109 ),现在需要你找到一对数a, b (a + b = n),并且使得LCM(a, b)尽可能的大,然后输出最大的 LCM(a, b)。
(为什么我每次看到题目都想去暴力。。Orz 题外话)
这道题先对 n = 2 的情况进行判断,从输出可以知道 n = 2 的时候 ans = 1。接着对 n 进行分情况讨论。当 n = 2k + 1 的时候,ans = k * (k + 1)。
当 n = 2k 的时候:
当 k 为偶数的时候 ans = (k + 1) * (k - 1)
当 k 为奇数的时候 ans = (k + 2) * (k - 2)
P.S : 杭电给的解题报告写反了。。Orz
这道题目的定位是签到题,就不多说了。
附AC代码:
1: #include <stdio.h>
2: #include <math.h>
3: #include <iostream>
4: #include <cstdarg>
5: #include <algorithm>
6: #include <string.h>
7: #include <stdlib.h>
8: #include <string>
9: #include <list>
10: #include <vector>
11: #include <map>
12: #define LL __int64
13: #define M(a) memset(a, 0, sizeof(a))
14: using namespace std;
15:
16: void Clean(int count, ...)
17: {
18: va_list arg_ptr;
19: va_start (arg_ptr, count);
20: for (int i = 0; i < count; i++)
21: M(va_arg(arg_ptr, int*));
22: va_end(arg_ptr);
23: }
24:
25: int main()
26: {
27: LL T;
28: cin >> T;
29: while (T--)
30: {
31: LL n;
32: cin >> n;
33: LL i = n / 2;
34: if (n == 2) cout << 1 << endl;
35: else if (n % 2) cout << (i * (i + 1)) << endl;
36: else if (i % 2) cout << ((i - 2) * (i + 2)) << endl;
37: else cout << ((i - 1) * (i + 1)) << endl;
38: }
39: return 0;
40: }
HDU 4627 The Unsolvable Problem 2013 Multi-University Training Contest 3的更多相关文章
- hdu 4627 The Unsolvable Problem【hdu2013多校3签到】
链接: http://acm.hdu.edu.cn/showproblem.php?pid=4627 The Unsolvable Problem Time Limit: 2000/1000 MS ( ...
- hdu 4627 The Unsolvable Problem(暴力的搜索)
Problem Description There are many unsolvable problem in the world.It could be about one or about ze ...
- hdu 4627 The Unsolvable Problem
http://acm.hdu.edu.cn/showproblem.php?pid=4627 分类讨论一下就可以 代码: #include<iostream> #include<cs ...
- HDU 4627 The Unsolvable Problem(简单题)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4627 题目大意:给定一个整数n(2 <= n <= 109),满足a+b=n并且[a,b] ...
- HDU 4627 The Unsolvable Problem 杭电多校联赛第三场1009 数学题
题意描述:给出一个n,要求在所有满足n = a+b的a和b里面求a和b的最小公倍数最大的两个数的最小公倍数. 解题报告:比赛的时候看到这个题的第一反应就是寻找这两个数一定是在a和b比较接近的地方找,这 ...
- HDU 6141 - I am your Father! | 2017 Multi-University Training Contest 8
思路来自 FXXL 最小树形图模板用kuangbin的 /* HDU 6141 - I am your Father! [ 最小树形图 ] | 2017 Multi-University Traini ...
- HDU 5775 Bubble Sort(线段树)(2016 Multi-University Training Contest 4 1012)
原址地址:http://ibupu.link/?id=31 Problem Description P is a permutation of the integers from 1 to N(ind ...
- hdu 6406 Taotao Picks Apples (2018 Multi-University Training Contest 8 1010)(二分,前缀和)
链接:http://acm.hdu.edu.cn/showproblem.php?pid=6406 思路: 暴力,预处理三个前缀和:[1,n]桃子会被摘掉,1到当前点的最大值,1到当前点被摘掉的桃子的 ...
- HDU 4946 Area of Mushroom(2014 Multi-University Training Contest 8)
思路: 只有速度最大才有可能为1,速度不是最大肯定为0,那么就是 只需要操作那些速度最大的点,这些点求一个凸包,判断一下是不是在凸包边上即可. 有几个需要注意的地方: 1.最大速度如果为0 那么肯 ...
随机推荐
- angularJS seed 安装
安装nodejs 安装python 配置python 环境 安装git 配置git 环境 clone angularJS seed 代码. 环境变量如下: C:\Program Files\nodej ...
- hdu 4762 Cut the Cake (大数乘法)
猜公式: ans=n/m^(n-1) #include<stdio.h> #include<string.h> struct BigNum { ]; int len; }; i ...
- LR_问题_平均响应时间解释,summary与analysis不一致
Summary Report中的时间说明 Summary是按整个场景的时间来做平均的,最大最小值,也是从整个场景中取出来的. (1) 平均响应时间:事物全部响应时间做平均计算 (2) ...
- TPaintBox的前世今生
TPaintBox是一个图形控件,继承于TGraphicControl,并且只有聊聊几个函数和属性,主要就是Canvas和Paint函数,都在这里了: TPaintBox = class(TGraph ...
- CentOS目录树详细解释
[sdm_download id=”292″ fancy=”1″] /boot 该目录默认下存放的是Linux的启动文件和内核. initramfs-* 系统启动时的模块供应的主要来源 启动系统所需加 ...
- struts2与spring mvc 的比较
1.传值: struts2通过set get来传值,而spring mvc 可以直接在方法里传值(String username,Model model)model也可以换成map来传值但不建义 mo ...
- c# 计算一个整型数组的平均
一个整型数组的平均: class Program { static void Main(string[] args) { ,,,,,,,,,}; double avg= GetAvg(array); ...
- Lantern免费使用教程【转】
转自:http://www.mfbuluo.com/13710.html 自从谷歌去年退出中国后,可能是意识到中国市场的潜力,所说这款Lantern免费的软件,背后有谷歌的资助,这一点部落无法肯定. ...
- git常见操作--忽略文件以及常用命令【转】
转自:http://www.cnblogs.com/elfsundae/archive/2011/07/17/2099698.html References: http://stackoverflow ...
- 无开发经验,初学python
1.无开发经验,初学python 如果你不会其他语言,python是你的第一门语言: A Byte of Python (简明python教程,这个有中文版简明 Python 教程)是非常好的入门 ...