题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=2446

题意:题面很大,有用的就那么几句,意思就是用自然数来堆它画的那个金字塔,比如第一个金字塔的第一个数为1,第二个金字塔的第一个数为2,第三个金字塔的第一个数为5……。

题解:可以打表,最多有381W个金字塔,然后用二分搜,也可以推个公式出来(n*n*n - n)/6表示第n-1堆的最后一个数,然后用求和公式算第几层第几列

  1. #include<cstdio>
  2. #include<cmath>
  3. #define ll unsigned long long
  4. int main(){
  5. int t;ll n;
  6. scanf("%d",&t);
  7. while(t--){
  8. scanf("%lld",&n);
  9. ll p=(ll)pow(n*6.0,1.0/);p++;
  10. while((p*p*p-p)>=n*6.0)p--;
  11. n-=(p*p*p-p)/;
  12. ll k=(ll)(sqrt(2.0*n));k++;
  13. while(k*(k+)/>=n)k--;
  14. ll j =k+,c=n-k*(k+)/;
  15. printf("%lld %lld %lld\n",p,j,c);
  16. }
  17. return ;
  18. }

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

  1. hdu 5432 Pyramid Split 二分

    Pyramid Split Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://bestcoder.hdu.edu.cn/contests/conte ...

  2. HDU 6216 A Cubic number and A Cubic Number(数学/二分查找)

    题意: 给定一个素数p(p <= 1e12),问是否存在一对立方差等于p. 分析: 根据平方差公式: 因为p是一个素数, 所以只能拆分成 1*p, 所以 a-b = 1. 然后代入a = b + ...

  3. UVA 10668 - Expanding Rods(数学+二分)

    UVA 10668 - Expanding Rods 题目链接 题意:给定一个铁棒,如图中加热会变成一段圆弧,长度为L′=(1+nc)l,问这时和原来位置的高度之差 思路:画一下图能够非常easy推出 ...

  4. Success Rate CodeForces - 807C (数学+二分)

    You are an experienced Codeforces user. Today you found out that during your activity on Codeforces ...

  5. AT2165 Median Pyramid Hard 二分答案 脑洞题

    无论再来多少次也不可能想到的写法. 二分一个最小的顶端值\(k\),大于设为\(1\)小于等于设为\(0\),可以证猜出来(你跟我说这可以?)如果存在两个连在一起的0/1那么它们会一直往上跑,还可以很 ...

  6. CF 483B. Friends and Presents 数学 (二分) 难度:1

    B. Friends and Presents time limit per test 1 second memory limit per test 256 megabytes input stand ...

  7. HDU 5646 DZY Loves Partition 数学 二分

    DZY Loves Partition 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5646 Description DZY loves parti ...

  8. [AGC006] D - Median Pyramid Hard 二分

    Description ​ 现在有一个NN层的方块金字塔,从最顶层到最底层分别标号为1...N1...N. ​ 第ii层恰好有2i−12i−1个方块,且每一层的中心都是对齐的. 这是一个N=4N=4的 ...

  9. UVA 11881 Internal Rate of Return(数学+二分)

    In finance, Internal Rate of Return (IRR) is the discount rate of an investment when NPV equals zero ...

随机推荐

  1. centos7下编译安装nginx1.10

    1.下载pcre 下载地址:ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/ 解压到/usr/local/pcre8.3.9 2.下载ope ...

  2. 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 ...

  3. 寻找中位数v1.0

    题目内容: 编写一个函数返回三个整数中的中间数.函数原型为: int mid(int a, int b, int c); 函数功能是返回a,b,c三数中大小位于中间的那个数. 输入格式: " ...

  4. Char device registration

    The kernel uses structures of type struct cdev to represent char devices internally. Include <lin ...

  5. Cookie的简单使用

    一,新建一个空网站,添加一个Default.aspx <%@ Page Language="C#" AutoEventWireup="true" Code ...

  6. 火狐中,设置align="center"失效的解决方法

    如下: <img align="center" style="vertical-align:top"></img> 只需要加上: ver ...

  7. js返回上一页并刷新代码整理

    一:JS 重载页面,本地刷新,返回上一页 复制代码 代码如下: <a href="javascript:history.go(-1)">返回上一页</a> ...

  8. c# 对象object转换

    object app = new { name = "hyt", age = 18 }; Type t = app.GetType(); var name = t.GetType( ...

  9. 洛谷-陶陶摘苹果(升级版)-BOSS战-入门综合练习1

    题目描述 Description 又是一年秋季时,陶陶家的苹果树结了n个果子.陶陶又跑去摘苹果,这次她有一个a公分的椅子.当他手够不着时,他会站到椅子上再试试. 这次与NOIp2005普及组第一题不同 ...

  10. "urllib"库的学习

    在习题—41遇到这个模块/库, 有兴趣的参考下面这个网址: http://blog.sina.com.cn/s/blog_b369b20d0101kb7m.html # coding: utf-8 i ...