hdu_2446_Shell Pyramid(数学,二分)】的更多相关文章

题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=2446 题意:题面很大,有用的就那么几句,意思就是用自然数来堆它画的那个金字塔,比如第一个金字塔的第一个数为1,第二个金字塔的第一个数为2,第三个金字塔的第一个数为5……. 题解:可以打表,最多有381W个金字塔,然后用二分搜,也可以推个公式出来(n*n*n - n)/6表示第n-1堆的最后一个数,然后用求和公式算第几层第几列 #include<cstdio> #include<cmath&g…
Pyramid Split Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://bestcoder.hdu.edu.cn/contests/contest_chineseproblem.php?cid=629&pid=1001 Description 小明是城会玩,他有很多底面是正方形的黄金锥体,我们称之为金字塔,它由高度和底面正方形边长可以确定,分别称之为金字塔的高和宽. 为了便于理解,单位统一取米.现在小明有nn个金字塔,已知它们的高和宽,小…
题意: 给定一个素数p(p <= 1e12),问是否存在一对立方差等于p. 分析: 根据平方差公式: 因为p是一个素数, 所以只能拆分成 1*p, 所以 a-b = 1. 然后代入a = b + 1. 求出 3a² + 3a + 1 = p 化简得a(a+1) = (p-1)/3 令(p-1)/3 = T, 问题化为是否存在整数a使得a(a+1) == T, 那么令 t = (int)sqrt(T),只要判定一下t * (t+1) == T ? 即可 另一种做法是打一个a的表(a只要打到1e6)…
UVA 10668 - Expanding Rods 题目链接 题意:给定一个铁棒,如图中加热会变成一段圆弧,长度为L′=(1+nc)l,问这时和原来位置的高度之差 思路:画一下图能够非常easy推出公式,设圆弧扇形部弧度r,那么能够计算出铁棒长度为lr/sin(r)这个公式在[0, pi/2]是单调递增的,所以能够用二分法去求解 要注意的一点是最后答案计算过程中带入mid,之前是带入x(二分的左边值),可实际上x是可能等于0的,而带入mid,因为是double型,所以mid实际上表示是一个很趋…
You are an experienced Codeforces user. Today you found out that during your activity on Codeforces you have made y submissions, out of which x have been successful. Thus, your current success rate on Codeforces is equal to x / y. Your favorite ratio…
无论再来多少次也不可能想到的写法. 二分一个最小的顶端值\(k\),大于设为\(1\)小于等于设为\(0\),可以证猜出来(你跟我说这可以?)如果存在两个连在一起的0/1那么它们会一直往上跑,还可以很容易就想到(容易?????)如果不存在相邻的情况(也就是交叉的那种)那么顶端答案一定是原先左右两边的值之一.. 不管了弃疗了.放代码. #include <bits/stdc++.h> using namespace std; const int N = 200010; int n, a[N &l…
B. Friends and Presents time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You have two friends. You want to present each of them several positive integers. You want to present cnt1 numbers to…
DZY Loves Partition 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5646 Description DZY loves partitioning numbers. He wants to know whether it is possible to partition n into the sum of exactly k distinct positive integers. After some thinking he f…
Description ​ 现在有一个NN层的方块金字塔,从最顶层到最底层分别标号为1...N1...N. ​ 第ii层恰好有2i−12i−1个方块,且每一层的中心都是对齐的. 这是一个N=4N=4的方块金字塔 ​ 现在,我们首先在最底层填入一个2N−12N−1的排列.之后,我们从i−1i−1层开始,逐步向上填入每一层的数. ​ 对于第ii(1≤i<N1≤i<N)层中位置为xx的方块,它的值为左下方.正下方和右下方的三个数的中位数.形式化地描述,就是i+1i+1层中x−1x−1.xx和x+1x…
In finance, Internal Rate of Return (IRR) is the discount rate of an investment when NPV equals zero. Formally, given T, CF0, CF1, ..., CFT, then IRR is the solution to the following equation: NPV = CF0 +  +  + K +  = 0 Your task is to find all valid…