Given a positive integer n, break it into the sum of at least two positive integers and maximize the product of those integers. Return the maximum product you can get. For example, given n = 2, return 1 (2 = 1 + 1); given n = 10, return 36 (10 = 3 +…
Galaxy Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others) Total Submission(s): 556 Accepted Submission(s): 127 Special Judge Problem Description Good news for us: to release the financial pressure, the government…
Friend HDU - 1719 Friend number are defined recursively as follows. (1) numbers 1 and 2 are friend number; (2) if a and b are friend numbers, so is ab+a+b; (3) only the numbers defined in (1) and (2) are friend number. Now your task is to judge wheth…
A - A Very Easy Triangle Counting Game Time Limit:1000MS Memory Limit:64000KB 64bit IO Format:%lld & %llu Submit Status Practice ACdream 1008 Description Speedcell and Shoutmon love triangles very much.One day,they are playing a game named “T…
Problem Description You live in a village but work in another village. You decided to follow the straight path between your house (A) and the working place (B), but there are several rivers you need to cross. Assume B is to the right of A, and all…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5312 Sequence Time Limit: 2000/2000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others) Total Submission(s): 1336 Accepted Submission(s): 410 Problem Description Today, Soda has learned a…
这个题目题意简单,但是TLE得哭哭的... 输入 a b w x c五个数,最终要使得c<=a, 每一秒可以进行一个操作,如果b>=x,则 b=b-x,同时 c--;如果b<x,则a--,c--,b=w-(x-b),最终求满足c<=a时候已经走过的秒数. 我们可以看到,x ,w是里面的定量,b相当于一个控制开关,它的量决定了要进行哪种操作,c在任意一秒都会递减,而a只会在b<x的时候递减,换句话说,b>=x的时候,c和a才差距减少1,我一开始的优化是,分别对于两个条件,…
来提供两个正确的做法: 斐波那契数列双倍项的做法(附加证明) 矩阵快速幂 一.双倍项做法 在偶然之中,在百度中翻到了有关于斐波那契数列的词条(传送门),那么我们可以发现一个这个规律$ \frac{F_{2n}}{F_{n}}=F_{n-1}+F_{n+1} $,那么我就想到了是不是可以用这个公式实现类似于快速幂之类的东西:power(n,m)=power(n*n,m/2) m mod 2=0 power(n,m)=power(n*n,m/2)*n m mod 2=1 快速幂这个东西,是分成偶数情…
SRM 146 2 500RectangularGrid Problem Statement Given the width and height of a rectangular grid, return the total number of rectangles (NOT counting squares) that can be found on this grid. For example, width = 3, height = 3 (see diagram below): __ _…