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 那么肯 ...
随机推荐
- 关于javascript获取页面高度宽度
在市容市政项目中,计算jqgrid的自适应高度时,发现jQuery(window).height()和jQuery(document).height()的数值有差异. 最初使用的是jQuery(doc ...
- asp.net跳转页面的三种方法比较
目前,对于学习asp.net的很多朋友来讲,实现跳转页面的方法还不是很了解.本文将为朋友们介绍利用asp.net跳转页面的三种方法,并对其之间的形式进行比较,希望能够对朋友们有所帮助. ASP.NET ...
- Android核心分析 之九Zygote Service
Zygote Service 在本章我们会接触到这两个单词: Zygote [生物] 受精卵, 接合子, 接合体 Spawn:产卵 通过这两个单词,我们就可以大体知道Zygote是干什么的了,就是叫老 ...
- React属性和状态对比
一.相似点 二.区别 三.如何区分 PS:所有的数据都可以变成属性
- FMX的综合评价
Cliff: 我个人觉得FMX值得学,因为可以做Mac软件,可以做Windows下的DirectUI,可以开发iOS/Android,而且是可视化开发,可利用RTL一切函数,包括可使用所有非可视控件. ...
- CentOS下对Apache的中文乱码处理
# vi /etc/sysconfig/i18nLANG="en_US.UTF-8"SYSFONT="latarcyrheb-sun16" 默认的语言是英文,如 ...
- centos 安装jdk
不要使用yum 安装openjdk,他妈的就是一坑货 首先到官网下载jdk,http://www.oracle.com/technetwork/java/javase/downloads/jdk7-d ...
- Database: Normal form
refer to wikipedia--- 1NF(first normal form): 1. There's no top-to-bottom ordering to the rows. 2. T ...
- javascript中对象的属性的特性
1.ES5的属性特性包括下面六个: configurable: 表示能否通过delete来删除属性从而重新定义属性,能够修改属性的特性,默认为true enumberable: 表示是否能通过for- ...
- @Factory和@DataProvider的区别
DataProvider: A test method that uses DataProvider will be executed a multiple number of times based ...