HDU-6217 BBP Formula 脑洞】的更多相关文章

题目链接: HDU 7217 题意: 题目给你可以计算 \(π\) 的公式: \(\pi = \sum_{k=0}^{\infty}[\frac{1}{16^k}(\frac{4}{8k+1})-(\frac{2}{8k+4})-(\frac{1}{8k+5})-(\frac{1}{8k+6})]\) 告诉你可以求十六进制下的小数点后 \(π\) 的第 \(n\) 位,而不用计算前 \(n-1\) 项. 十六进制表示下,问你 \(π\) 的小数点后的第 \(n\) 位是多少 $ (1 ≤ n ≤…
题目链接:https://cn.vjudge.net/problem/HDU-6217 题意 已知: \[ \pi = \sum_{k=0}^{\infty }\frac{1}{16^{k}}(\frac{4}{8k+1}-\frac{2}{8k+4}-\frac{1}{8k+5}-\frac{1}{8k+6}) \] 求pi的16进制下小数点后第n位是多少. n<=1e5 思路 要算pi的第n位,首先把pi向前移n位,则个位上就是要求的数. 但是我们很快发现难以计算这个个位数(乘法逆元可能不存…
题意 已知公式:$\pi=\sum_{k=0}^{\infty}\left[\frac{1}{16^{k}}\left(\frac{4}{8 k+1}-\frac{2}{8 k+4}-\frac{1}{8 k+5}-\frac{1}{8 k+6}\right)\right]$ 求 $\pi$ 的第 $n$ 项. 分析 WIKI上有:π的BBP位抽取算法 这类公式是用来求解一些无理数常数的公式,特点是不需要求解前n-1位也能去算第n位 将公式乘以 $16^n$ 就能将小数点移动到第 $n$ 位.…
题意:给定一个无穷项的分式,它的和等于π,问π的十六进制表示的小数点后第n位是多少 1 ≤ n ≤ 100000 思路:From https://blog.csdn.net/meopass/article/details/78327614 C++double写起来细节真是烦 #include<cstdio> #include<cstring> #include<string> #include<cmath> #include<iostream>…
8201-BBP Formula Time limit: 3.000 seconds In 1995, Simon Plouffe discovered a special summation style for some constants. Two year later, together with the paper of Bailey and Borwien published, this summation style was named as the Bailey-Borwein-P…
A: BBP Formula https://www.cnblogs.com/LzyRapx/p/7802790.html #include <bits/stdc++.h> using namespace std; #define ll long long inline ll qpow(ll x, ll n, ll mod) { ll base = x; ll ans = ; while (n) { ) ans = (ans * base) % mod; base = base * base…
题目链接:http://acm.hdu.edu.cn/listproblem.php?vol=44 题意:给你n个n,如果能在n-1次运算之后(加减乘除)结果为24的输出n-1次运算的过程,如果不能输出-1. 思路:乍看起来,没什么规律,但是可以想象的是(n+n+n+n)/n=4,(n+n+n+n+n+n)/n=6,(n-n)*n*n*·····*n=0所以在n大于15的时候结果基本是固定的,只要对小于15的数一一输出就行(但是这题真是无语,算这种题目真是累,脑洞啊~~) 代码: #includ…
http://acm.hdu.edu.cn/showproblem.php?pid=2139 Problem Description You just need to calculate the sum of the formula: 1^2+3^2+5^2+……+ n ^2.   Input In each case, there is an odd positive integer n.   Output Print the sum. Make sure the sum will not e…
http://acm.hdu.edu.cn/showproblem.php?pid=5139 思路:这道题要先找规律,f(n)=n!*(n-1)!*(n-2)!.....1!;  不能直接打表,而是离线处理,一次性处理出来. #include <cstdio> #include <cstring> #include <map> #include <algorithm> #define ll long long #define mod 1000000007 #…
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) 看到这个时间,我懵逼了... 果然,Java就是打表,都不能AC,因为Java的输入是流,需要的时间比C真的长好多.... Problem Description You just need to calculate the sum of the formula: 1^2+3^2+5^2+--+ n ^2. Input In each…
传送门: http://acm.hdu.edu.cn/showproblem.php?pid=2088 Box of Bricks Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 20219    Accepted Submission(s): 6473 Problem Description Little Bob likes playi…
题意就不说了,求公式. 解法: 稍加推导能够得出 : f(n) = n! * f(n-1) , 即其实是求: ∏(n!)  ,盲目地存下来是不行的,这时候看见条件: 数据组数 <= 100000, 那么我们可以离线做,先把他们存下来,然后再从小到大扫一边, 也就是最多10000000次乘法的复杂度.然后离线输出即可. 代码: #include <iostream> #include <cstdio> #include <cstring> #include <…
插头DP基础题的样子...输入N,M<=11,以及N*M的01矩阵,0(1)表示有(无)障碍物.输出哈密顿回路(可以多回路)方案数... 看了个ppt,画了下图...感觉还是挺有效的... 参考http://www.cnblogs.com/kuangbin/archive/2012/10/02/2710343.html 以及推荐cd琦的论文ppthttp://wenku.baidu.com/view/4fe4ac659b6648d7c1c74633.html 向中学生学习~~ 感觉以后可能还会要…
题目就是求这个 n达到10^7,测试数据组数为10^5 为了防止TLE,一开始把每个n对应的值先求出来,但发现竟然开不了10^7的数组(MLE),然后就意识到这是第一道卡内存的题目... 只能离线做,把每个n从小到大排序,然后从小到大依次求,然后把结果存下来,最后排回去输出. #include<cstdio> #include<cstring> #include<cmath> #include<iostream> #include<algorithm&…
给定一个序列,里面的0是可以任变的.问变化后最长的LIS的长度 首先,0全部选上是不亏的.这个不知道怎么说,YY一下吧. 最关键的就是解决2 0 0 3 这种问题了. 注意到这个序列的LIS应该是3 也就是你求LIS的时候,是不能包括0的,因为0是最后全部加上去的.这样你求到的LIS只能是1. 再来一组数据 2 0 0 3 0 0 4 这样的LIS是5,也就是你求到的LIS只能是1. 这样的话,只有2 1 0求到的LIS是1了. 也就是每个数减去它前面出现过多少个0,再求一次LIS. 关键要抓住…
题目链接 题意 将\(x\)拆成\(a_1+a_2+...+\)的形式,且\(a_1\lt a_2\lt...\),使得\(a_1*a_2*...\)取到最大值 思路 大胆猜结论. 首先拆分的形式中肯定不能有\(1\). 于是预处理出前缀和\(a[i]=\sum_{k=2}^{i}k\), 找到\(\geq x\)的最小的\(a[id]\),接下来: 如果\(a[id]==x\),意味着\(2+3+...+id=x\),那么答案就是\(2*3*...*id=factorial(id)\) 否则,…
线段树,TLE,各种.唉....我真是笨死了.... 我用的线段树是记录左右区间最长连续棵数的...反正TLE #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> using namespace std; const int N=50050; struct Q{ int val,index; }Que[N]; int SegT[N*4],L[N*4],R[…
Problem Description You may heard of the Joseph Problem, the story comes from a Jewish historian living in 1st century. He and his 40 comrade soldiers were trapped in a cave, the exit of which was blocked by Romans. They chose suicide over capture an…
Sequence II Time Limit: 9000/4500 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Total Submission(s): 1422    Accepted Submission(s): 362 Problem Description Mr. Frog has an integer sequence of length n, which can be denoted as a1,a2…
链接:http://acm.hdu.edu.cn/showproblem.php?pid=2141 Can you find it? Time Limit: 10000/3000 MS (Java/Others)    Memory Limit: 32768/10000 K (Java/Others)Total Submission(s): 11503    Accepted Submission(s): 3021 Problem Description Give you three seque…
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=2141 Can you find it? Description Give you three sequences of numbers A, B, C, then we give you a number X. Now you need to calculate if you can find the three numbers Ai, Bj, Ck, which satisfy the formu…
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5280 Senior's Array Description One day, Xuejiejie gets an array $A$. Among all non-empty intervals of $A$, she wants to find the most beautiful one. She defines the beauty as the sum of the interval. Th…
Fibonacci Check-up Problem Description Every ALPC has his own alpc-number just like alpc12, alpc55, alpc62 etc.As more and more fresh man join us. How to number them? And how to avoid their alpc-number conflicted? Of course, we can number them one by…
转载请注明出处:http://blog.csdn.net/u012860063?viewmode=contents 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2876   HDU集训队选拔赛地点:3教3楼机房,时间:5月10日(周六)12:00開始,请相互转告,谢谢~ 百度之星编程大赛--您报名了吗?  Ellipse, again and again Time Limit: 2000/1000 MS (Java/Others)    Memo…
Fraction Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 0    Accepted Submission(s): 0 Problem Description Mr. Frog recently studied how to add two fractions up, and he came up with an evil ide…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4940 Destroy Transportation system Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Total Submission(s): 21    Accepted Submission(s): 17 Problem Description Tom is a…
主题链接:http://acm.hdu.edu.cn/showproblem.php? pid=5073 Galaxy Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) Total Submission(s): 768    Accepted Submission(s): 179 Special Judge Problem Description Good news for…
主题链接:http://acm.hdu.edu.cn/showproblem.php? pid=5073 Galaxy Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) Total Submission(s): 768    Accepted Submission(s): 179 Special Judge Problem Description Good news for…
HDU 5073 Galaxy (2014 Anshan D简单数学) 题目链接http://acm.hdu.edu.cn/showproblem.php?pid=5073 Description Good news for us: to release the financial pressure, the government started selling galaxies and we can buy them from now on! The first one who bought…
u Calculate e Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 46844    Accepted Submission(s): 21489 Problem Description A simple mathematical formula for e is where n is allowed to go to infini…