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 ...
随机推荐
- linux的命令使用记录
iptables禁止53端口的出包(dns) iptables -A OUTPUT -p udp --dport 53 -j DROP linux查看网络监听端口 netstat -npl 文件复制 ...
- IE8及以下不支持getElementByClassName的解决办法
function getByClass(oParent, sClass){ var aEle=oParent.getElementsByTagName('*'); var aResult=[]; va ...
- Matches Puzzle Game
Matches Puzzle Game 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5456 数位DP 首先我把C-A=B改为A+B=C(我觉得会简单 ...
- iframe、flash引入
iframe引入 <iframe src="" width="" height="" frameborder="0" ...
- JavaScript的DOM(文档对象)基础语法总结1
---恢复内容开始--- 前言:HTML文档可以说由节点构成的集合,DOM节点有: 1). 元素节点:上图中<html>.<body>.<p>等都是元素节点,即标签 ...
- hdu_5193_Go to movies Ⅱ(带插入删除的逆序对,块状链表)
题目链接:hdu_5193_Go to movies Ⅱ 题意: 有n个人站成一排,每个人的身高为Hi.每次有人加入或者有人离开,就要判断有多少人站反了(i < j&&Hi> ...
- shell脚本学习(五)
1.统计文件的行数.单词数.字符数 1)行数: wc -l file cat file | wc -l 2)单词数 wc -w file cat file | wc -w 3)统计字符数 wc -c ...
- ubutun下安装jenkins
安装方法所在网址: https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins+on+Ubuntu 在安装jenkins之前,ub ...
- [ An Ac a Day ^_^ ] Codeforces Round #368 Div. 2 A B C
昨天才回学校 刚好赶上CF所以就没写博客 不过还是水题了…… A. 比赛的时候被hack了 仔细读题才知道grey也算是黑白的 英语不好好伤心…… #include<stdio.h> #i ...
- Arch安装详解
选择安装方式 CD/USB Arch启动盘安装 使用Arch启动盘比较简单方便,没有额外设置,直接阅读下一步. USB flash installation media 启动盘制作: USB flas ...