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>
- #define ll unsigned long long
- int main(){
- int t;ll n;
- scanf("%d",&t);
- while(t--){
- scanf("%lld",&n);
- ll p=(ll)pow(n*6.0,1.0/);p++;
- while((p*p*p-p)>=n*6.0)p--;
- n-=(p*p*p-p)/;
- ll k=(ll)(sqrt(2.0*n));k++;
- while(k*(k+)/>=n)k--;
- ll j =k+,c=n-k*(k+)/;
- printf("%lld %lld %lld\n",p,j,c);
- }
- return ;
- }
hdu_2446_Shell Pyramid(数学,二分)的更多相关文章
- hdu 5432 Pyramid Split 二分
Pyramid Split Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://bestcoder.hdu.edu.cn/contests/conte ...
- HDU 6216 A Cubic number and A Cubic Number(数学/二分查找)
题意: 给定一个素数p(p <= 1e12),问是否存在一对立方差等于p. 分析: 根据平方差公式: 因为p是一个素数, 所以只能拆分成 1*p, 所以 a-b = 1. 然后代入a = b + ...
- UVA 10668 - Expanding Rods(数学+二分)
UVA 10668 - Expanding Rods 题目链接 题意:给定一个铁棒,如图中加热会变成一段圆弧,长度为L′=(1+nc)l,问这时和原来位置的高度之差 思路:画一下图能够非常easy推出 ...
- Success Rate CodeForces - 807C (数学+二分)
You are an experienced Codeforces user. Today you found out that during your activity on Codeforces ...
- AT2165 Median Pyramid Hard 二分答案 脑洞题
无论再来多少次也不可能想到的写法. 二分一个最小的顶端值\(k\),大于设为\(1\)小于等于设为\(0\),可以证猜出来(你跟我说这可以?)如果存在两个连在一起的0/1那么它们会一直往上跑,还可以很 ...
- CF 483B. Friends and Presents 数学 (二分) 难度:1
B. Friends and Presents time limit per test 1 second memory limit per test 256 megabytes input stand ...
- HDU 5646 DZY Loves Partition 数学 二分
DZY Loves Partition 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5646 Description DZY loves parti ...
- [AGC006] D - Median Pyramid Hard 二分
Description 现在有一个NN层的方块金字塔,从最顶层到最底层分别标号为1...N1...N. 第ii层恰好有2i−12i−1个方块,且每一层的中心都是对齐的. 这是一个N=4N=4的 ...
- UVA 11881 Internal Rate of Return(数学+二分)
In finance, Internal Rate of Return (IRR) is the discount rate of an investment when NPV equals zero ...
随机推荐
- centos7下编译安装nginx1.10
1.下载pcre 下载地址:ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/ 解压到/usr/local/pcre8.3.9 2.下载ope ...
- dump报文转换为wrieshark报文
我们开发中经常会出原始的报文,如下所示: 45 00 01 3d 8e 6a 00 00 80 11 ab 46 00 00 00 00 ff ff ff ff 00 44 00 43 01 29 6 ...
- 寻找中位数v1.0
题目内容: 编写一个函数返回三个整数中的中间数.函数原型为: int mid(int a, int b, int c); 函数功能是返回a,b,c三数中大小位于中间的那个数. 输入格式: " ...
- Char device registration
The kernel uses structures of type struct cdev to represent char devices internally. Include <lin ...
- Cookie的简单使用
一,新建一个空网站,添加一个Default.aspx <%@ Page Language="C#" AutoEventWireup="true" Code ...
- 火狐中,设置align="center"失效的解决方法
如下: <img align="center" style="vertical-align:top"></img> 只需要加上: ver ...
- js返回上一页并刷新代码整理
一:JS 重载页面,本地刷新,返回上一页 复制代码 代码如下: <a href="javascript:history.go(-1)">返回上一页</a> ...
- c# 对象object转换
object app = new { name = "hyt", age = 18 }; Type t = app.GetType(); var name = t.GetType( ...
- 洛谷-陶陶摘苹果(升级版)-BOSS战-入门综合练习1
题目描述 Description 又是一年秋季时,陶陶家的苹果树结了n个果子.陶陶又跑去摘苹果,这次她有一个a公分的椅子.当他手够不着时,他会站到椅子上再试试. 这次与NOIp2005普及组第一题不同 ...
- "urllib"库的学习
在习题—41遇到这个模块/库, 有兴趣的参考下面这个网址: http://blog.sina.com.cn/s/blog_b369b20d0101kb7m.html # coding: utf-8 i ...