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 ≤…
题意 已知公式:$\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$ 位.…
C - History repeat itself Time Limit:1000MS     Memory Limit:32768KB      Description Tom took the Discrete Mathematics course in the 2011,but his bad attendance angered Professor Lee who is in charge of the course. Therefore, Professor Lee decided t…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4816 Problem Description The Bathysphere is a spherical deep-sea submersible which was unpowered and lowered into the ocean on a cable, and was used to conduct a series of dives under the sea. The Bathys…
LCM Walk Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5584 Description A frog has just learned some number theory, and can't wait to show his ability to his girlfriend. Now the frog is sitting on a grid map o…
题目地址: http://acm.hdu.edu.cn/showproblem.php?pid=4336 题意简单,直接用容斥原理即可 AC代码: #include <iostream> #include <cstdio> #include <cstring> #include <string> #include <cstdlib> #include <cmath> #include <vector> #include &…
balls Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5570 Description There are n balls with m colors. The possibility of that the color of the i-th ball is color j is ai,jai,1+ai,2+...+ai,m. If the number of b…
意甲冠军:那是,  从数0-n小球进入相应的i%a箱号.然后买一个新的盒子. 今天的总合伙人b一个盒子,Bob试图把球i%b箱号. 求复位的最小成本. 每次移动的花费为y - x ,即移动前后盒子编号的差值的绝对值. 算法: 题目就是要求                  watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvdTAxMjg0MTg0NQ==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissol…
链接:pid=4790">http://acm.hdu.edu.cn/showproblem.php?pid=4790 意:从[a.b]中随机找出一个数字x,从[c.d]中随机找出一个数字y.给出p.m,假设(x+y)%p==m则算成功,问成功的概率是多少. 思路:[a.b]中连续p个数.[c,d]中连续p个数.用这2*p个数进行组合能找到p种的成功组合(详细不证),所以找到[a.b]中p循环的个数x1,[c,d]中p循环的个数y1,则它们组成的成功组合数为p*x1*y1. 然后是处理边界…
Big Number Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 26383    Accepted Submission(s): 12006 Problem Description In many applications very large integers numbers are required. Some of thes…
Equations 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1840 ——每天在线,欢迎留言谈论. 题目大意: 给你一个一元二次方程组,a(X^2) + b(X) + c = 0 .求X解的个数. 思路: 分别讨论二次方程与一次方程的情况,再特殊处理下 a = b = c = 0 的情况. 感想: 是时候该水水题了. Java AC代码: import java.math.*; import java.util.Scanner; public…
Lucky Coins 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5985 Description Bob has collected a lot of coins in different kinds. He wants to know which kind of coins is lucky. He finds out a lucky kind of coins by the following way. He tosses all th…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4472 Problem Description Prof. Tigris is the head of an archaeological team who is currently in charge of an excavation in a site of ancient relics. This site contains relics of a village where civilizat…
All X 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5690 Description F(x,m) 代表一个全是由数字x组成的m位数字.请计算,以下式子是否成立: F(x,m) mod k ≡ c Input 第一行一个整数T,表示T组数据. 每组测试数据占一行,包含四个数字x,m,k,c 1≤x≤9 1≤m≤1010 0≤c<k≤10,000 Output 对于每组数据,输出两行: 第一行输出:"Case #i:".i代表…
Balls Rearrangement 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=4611 Description Bob has N balls and A boxes. He numbers the balls from 0 to N-1, and numbers the boxes from 0 to A-1. To find the balls easily, he puts the ball numbered x into the…
so easy 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5650 Description Given an array with n integers, assume f(S) as the result of executing xor operation among all the elements of set S. e.g. if S={1,2,3} then f(S)=0. your task is: calculate xor…
传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1220 Cube Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 2627    Accepted Submission(s): 2064 Problem Description Cowl is good at solving math pro…
title: Equations 数学 杭电1840 tags: [数学] 题目链接 Problem Description All the problems in this contest totally bored you. And every time you get bored you like playing with quadratic equations of the form aX2 + bX + c = 0. This time you are very curious to…
pid=5105" target="_blank" style="">题目链接:hdu 5105 Math Problem 题目大意:给定a.b,c,d.l,r.表示有一个函数f(x)=|a∗x3+b∗x2+c∗x+d|(L≤x≤R),求函数最大值. 解题思路:考虑极点就可以,将函数求导后得到f′(x)=0的x,即为极值点.在极值点处函数的单调性会发生变化,所以最大值一定就在区间边界和极值点上.注意a=0.b=0的情况,以及极值点不在区间上. #in…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5512 学习菊苣的博客,只粘链接,不粘题目描述了. 题目大意就是给了初始的集合{a, b},然后取集合里的两个元素进行加或者减的操作,生成新的元素.问最后最多能生成多少个元素.问答案的奇偶性. 首先一开始有a, b.那么如果生成了b-a(b>a),自然原来的数同样可以由b-a, a生成(b != 2a). 于是如此反复下去,最后的数必然是可以由两个数p, 2p生成的. 于是所有的数肯定可以表示成xp+…
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 a galaxy was Tianming Yun and he gave it to Xin Cheng as a present. To be fashionable,…
本题假设编程是使用DP思想直接打表就能够了. 假设是找规律就须要数学思维了. 规律就是看这些连续的0是从哪里来的. 我找到的规律是:1经过两次裂变之后就会产生一个00: 00经过两次裂变之后也会产生新的00:故此须要记录好1和00出现的次数就能够递推出后面的00出现的数据了. 公式就是tbl00[i] = tbl00[i-2] + tbl1[i-2]; 当中tbl00是记录00出现的次数,tbl1是出现1出现的次数. 公式事实上是能够化简的,只是我懒得化简了.这种公式非常清楚了. 只是因为这种数…
题意:给定一个无穷项的分式,它的和等于π,问π的十六进制表示的小数点后第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>…
http://acm.hdu.edu.cn/showproblem.php?pid=3117 fib是有一个数学公式的. 这里的是标准的fib公式 那么fib = 1 / sqrt(5) * ((1 + sqrt(5) / 2) ^ n - ((1 - sqrt(5)) / 2)^n) = 1 / sqrt(5) * (A^n - B^n) 那么,求后4位可以直接矩阵快速幂. 不能用上面公式的快速幂取模,因为存在精度误差. 然后求前4位的话,就是一个套路公式了. 在上一篇博客.http://ww…
http://acm.hdu.edu.cn/showproblem.php?pid=4565 首先知道里面那个东西,是肯定有小数的,就是说小数部分是约不走的,(因为b限定了不是一个完全平方数). 因为(a - 1)^2 < b < (a ^ 2),所以其不是完全平方数,假如是,那么设其为c,则有a - 1 < c < a,这是矛盾的 所以,向上取整这个步骤,是必不可少的了. 那么,我在它后面加上一个< 1的数,同时使得它们结合成为整数,那就相当于帮它取整了.根据二项式定理 (…
题意:有两个盒子各有n个糖(n<=2*105),每天随机选1个(概率分别为p,1-p),然后吃掉一颗糖.直到有一天打开盒子一看,这个盒子没有糖了.输入n,p,求此时另一个盒子里糖的个数的数学期望. 思路:假设没糖的是A盒子,而B盒子还有0~n个糖.由于B盒子还有0个糖的情况的期望必为0,所以省略,只需要计算1~n的. (1)当A盒没有糖时,B盒就可能有1~n个糖,概率为C(n+i,i)*(pn+1)*(1-p)n-i.为啥还带个大C?这是情况的种数(想象取糖时还有个顺序,有C种可能的顺序),不然…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4386 Problem Description One day the little Jack is playing a game with four crabsticks. The game is simple, he want to make all the four crabsticks to be a quadrilateral, which has the biggest area in a…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5312 Sequence Time Limit: 2000/2000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) Total Submission(s): 1336    Accepted Submission(s): 410 Problem Description Today, Soda has learned a…
Problem Description In many applications very large integers numbers are required. Some of these applications are using keys for secure transmission of data, encryption, etc. In this problem you are given a number, you have to determine the number of…
HDU - 5528Count a * b 照着这个写的,忘了哪个大佬博客里的了, 但很多初学者,像我一样可能不懂其中一些符号的意义,还有为什么可以这样推导,所以我自己又推导了一下,并用自己的观点解释了下一些自己不懂的过程. 至于mod264,是因为中途计算结果可能超long long,所以注意使用unsigned long long #include<cstdio> typedef unsigned long long ull; typedef long long ll; ; bool no…