
数据结构-高精度
文章平均质量分 58
JeraKrs
本人目前就职于百度商业研发部,有需要内推的朋友简历可发我邮箱 jerakrs@qq.com
展开
-
uva 10106 Product(高精度乘法)
Product The ProblemThe problem is to multiply two integers X, Y. (0250)The InputThe input will consist of a set of pairs of lines. Each line in pair contains one multip原创 2013-07-25 20:59:16 · 1611 阅读 · 0 评论 -
hdu 1133 Buy the Ticket(卡特兰数 + 高精度)
题目连接:1133 Buy the Ticket题目大意:有n + m 个人去电影院买票, 每张票卖50块, 现在m 个人手上有50快, n个人手上是100块, 然后电影院的售票厅又没有准备零钱, 问,n + m个人有多少种排队的方式可以使得售票可以不用中断, 中断是因为没有零钱可以找回。解题思路:问题可以简单理解成将n + m个人排序, 满足任意一个位置前, 拿100的人原创 2013-09-03 21:09:10 · 1678 阅读 · 0 评论 -
uva 10069 Distinct Subsequences(高精度 + DP求解子串个数)
题目连接:10069 - Distinct Subsequences题目大意:给出两个字符串x (lenth 解题思路:二维数组DP, 有类似于求解最长公共子序列, cnt[i][j]表示在x的前j个字符中有多少个z 前i个字符。状态转移方程 1、x[j] != z[i] cnt[i][j] = cnt[i][j - 1];2、x[j原创 2013-09-05 15:20:15 · 1833 阅读 · 0 评论 -
uva 10023 - Square root(手动开方)
题目链接:uva 10023 - Square root题目大意:给出一个出,然后你求他的开方,这个数最大为10^1000。解题思路:手动开方的算法很容易就在网上找到了,但是10^1000次方明显的用到高精度,而开方的算法又用到加减乘除。。。所以就是坑,写了一整天,就当是复习大数好了。开方算法#include #include #原创 2013-11-09 20:47:46 · 2056 阅读 · 0 评论 -
uva 748 Exponentiation(高精度实数乘法)
Exponentiation Problems involving the computation of exact values of very large magnitude and precision are common. For example, the computation of the national debt is a taxing experi原创 2013-07-20 21:34:47 · 1450 阅读 · 0 评论 -
hdu 4762 Cut the Cake(推导+高精度)
题目链接:hdu 4762 Cut the Cake题目大意:给出m和n,表示说在一块蛋糕上要分成m份,然后有n个草莓,随机分布在蛋糕上,现在你为切蛋糕的人,你想要尽量多的草莓,问说你获得所有草莓的概率。解题思路:p = n*(1/m)^(n-1),要用到高精度,公式推导:首先假设i号草莓为切点,那么有n种可能(每个草莓都有可能作为切点,即极角最小的),那么该种情况下,想要原创 2014-03-09 20:16:33 · 1150 阅读 · 0 评论 -
uva 10497 - Sweet Child Makes Trouble(dp+高精度)
题目链接:uva 10497 - Sweet Child Makes Trouble题目大意:有个小屁孩很淘气,总是趁父母不在家的时候去拿家具玩,每次拿n个家具玩,但是放回去的时候一定不会将某个物品放回原处,一定要打乱。问说有多少放的方式满足。解题思路:dp[i]表示说i个数打乱的情况,dp[i]=(dp[i−1]+dp[i−2])∗(i−1)每次新增一个数,放在序列的最后一个位置原创 2014-05-22 21:36:32 · 1418 阅读 · 0 评论 -
uva 10844 - Bloques(数论+高精度)
题目链接:uva 10844 - Bloques题目大意:给出一个n,表示有1~n这n个数,问有多少种划分子集的方法。解题思路:递推+高精度。11 22 3 55 7 10 1515 20 27 37 52dp[i][j]=dp[i−1][j−1]+dp[i][j−1]dp[i][0]=dp[i−1][i−1]ans[i]=dp[i][i]原创 2014-06-27 14:13:55 · 1233 阅读 · 0 评论 -
hdu 4873 ZCC Loves Intersection(大数+概率)
题目链接:hdu 4873 ZCC Loves Intersection题目大意:给出N,D,表示在一个D维的坐标上,坐标范围为0~N-1。在这个坐标系中有D条线段,分别平行与各个坐标轴,每秒会根据题目中的伪代码随机生成各个线段的位置。两条直线相交的话会得一分,问每秒得分的期望。解题思路:总的情况(ND−1∗C(2N))D,两条直线相交的得分C(2D)∗s2∗ND−2∗(ND−2∗原创 2014-07-24 21:54:50 · 1359 阅读 · 0 评论 -
uva 1478 - Delta Wave(递推+大数+卡特兰数+组合数学)
题目链接:uva 1478 - Delta Wave题目大意:对于每个位置来说,可以向上,水平,向下,坐标不能位负,每次上下移动最多为1, 给定n问说有多少种不同的图。结果对10100取模。解题思路:因为最后都要落回y=0的位置,所以上升的次数和下降的次数是相同的,并且上升下降的关系满足出栈入栈的关系。即卡特兰数。所以每次枚举i,表示有i个上升,i个下降,用组合数学枚举出位置,原创 2014-07-30 22:30:03 · 1347 阅读 · 0 评论 -
poj 1625 Censored!(AC自动机+DP+高精度)
题目链接:poj 1625 Censored!题目大意:给定N,M,K,然后给定一个N字符的字符集和,现在要用这些字符组成一个长度为M的字符串,要求不包括K个子字符串。解题思路:AC自动机+DP+高精度。这题恶心的要死,给定的不能匹配字符串里面有负数的字符情况,也算是涨姿势了,对应每个字符固定偏移128单位。#include #include #includ原创 2014-11-09 23:08:27 · 928 阅读 · 0 评论 -
hdu 5351 MZL's Border (大数)
题目链接:hdu 5351 MZL's Border#include #include #include #include #include #include using namespace std;typedef long long ll;const int maxn = 1005;struct bign { int len, num[300];原创 2015-08-05 15:13:54 · 643 阅读 · 0 评论 -
hdu 2100 Lovekey(进制下的高精度加法)
题目连接:2100 Lovekey解题思路:直接加法模拟, 只是将10 换成26.#include #include const int N = 205;int change(char *str, int num[]) { int len = strlen(str); memset(num, 0, sizeof(num)); for (int原创 2013-09-02 21:52:50 · 1450 阅读 · 0 评论 -
hdu 1753 大明A+B(实数高精度)
题目连接:1753 大明A+B解题思路:将实数的整数部分和小数数部分分开储存, 小数部分正序储存,由两个数中小数位数最大的地方开始相加(普通的高精度加法), 注意赋值的时候要清零,这里默认没有位数的地方为零。 如果加到i =0位后任有剩, 要保留到整数为进行加法。#include #include const int N = 405;struct bign {原创 2013-09-02 19:23:55 · 1710 阅读 · 0 评论 -
hdu 1042 N!(高精度乘法 + 缩进)
题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=1042题目大意:求n!, n 的上限是10000。解题思路:高精度乘法 , 因为数据量比较大, 所以得用到缩进,但因为是乘法,缩进只能在10^5, 不然在乘的过程中就超过int型。然后数值位数大概在8000位以下。#include #include using n原创 2013-08-20 16:18:31 · 1102 阅读 · 0 评论 -
uva 465 Overflow(借助double型进行比较)
Overflow Write a program that reads an expression consisting of two non-negative integer and an operator. Determine if either integer or the result of the expression is too large to be原创 2013-07-25 21:03:56 · 1448 阅读 · 0 评论 -
uva 10494 If We Were a Child Again(高精度与低精度求模和商)
If We Were a Child AgainInput: standard inputOutput: standard outputTime Limit: 7 seconds “Oooooooooooooooh!If I could do the easy mathematics like my school days!!I can guarante原创 2013-07-25 21:09:07 · 1404 阅读 · 0 评论 -
uva 424 Integer Inquiry(高精度加法)
Integer Inquiry One of the first users of BIT's new supercomputer was Chip Diller. He extended his exploration of powers of 3 to go from 0 to 333 and he explored taking various sums of原创 2013-07-25 20:55:53 · 1238 阅读 · 0 评论 -
poj 2756 Autumn is a Genius(高精度加法)
题目连接:http://poj.org/problem?id=2756题目大意:求两个数的和,题目给出了上限,却没有给出下限,所以可以是负的无穷大。解题思路:模板套用(写模板的时候有考虑正负)。模板连接:http://blog.youkuaiyun.com/keshuai19940722/article/details/10087993int main()原创 2013-08-20 00:06:37 · 1587 阅读 · 0 评论 -
hdu 1715 大菲波数(高精度加法+打表 + 斐波那契数)
题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=1715题目大意:求第N个菲波数 f(x) = f(x - 1) + f(x - 2).解题思路:因为要求到第1000个,所以非常数值非常大,得用高精度做。题目已经确定1000个了,可以打表,以防超时。模板连接:http://blog.youkuaiyun.com/keshu原创 2013-08-20 09:54:38 · 1205 阅读 · 1 评论 -
hdu 1297 Children’s Queue(高精度加法+情况分析+打表)
题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=1297题目大意:校长要给孩子们排队,要求不能有单独的女孩子站在最后,问,对于n个人(男女不限)的合法队列有多少。解题思路:num[n] = num[i - 1] + num[ i - 2] + num[i - 4];不懂的话介绍一篇:http://www.cnblogs.co原创 2013-08-20 10:28:47 · 1015 阅读 · 0 评论 -
hdu 1316 How Many Fibs?(高精度加法+ 斐波那契数)
题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=1316题目大意:给出两个数,求两个数之间有多少个斐波那契数。解题思路:通过打表的方式将斐波那契数求到10^100,大概450个左右,然后找到给出的两个数的下标(前后大小不一定)。模板连接:http://blog.youkuaiyun.com/keshuai19940722/art原创 2013-08-20 13:59:36 · 1004 阅读 · 0 评论 -
hdu 1002 A + B Problem II(高精度加法)
题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=1002题目大意:求两个大数的和。解题思路:高精度加法模板。模板连接:http://blog.youkuaiyun.com/keshuai19940722/article/details/10087993int main() { int n, cas = 1原创 2013-08-20 11:07:01 · 1119 阅读 · 0 评论 -
hdu 1865 1sting((高精度加法+ 斐波那契数)
题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=1865题目大意:给出n 个1, 两个相邻的1 可以合成2,问给出的字符串有多少种表现形式。解题思路:这题就是变相的斐波那契数,num[i] = num[i -1] + num[i - 2];模板连接:http://blog.youkuaiyun.com/keshuai1994原创 2013-08-20 14:40:31 · 1269 阅读 · 0 评论 -
hdu 1250 Hat's Fibonacci(高精度加法+缩进+斐波那契数)
题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=1250题目大意:求一个斐波那契数列的第n 项, n的上限是10000.解题思路:因为本题的上限是10000,所以对于高精度要进行缩进。#include #include using namespace std;const int MAXN = 10000000原创 2013-08-20 15:45:28 · 1378 阅读 · 0 评论 -
poj 2389 Bull Math(高精度加法)
题目连接:http://poj.org/problem?id=2389解题思路:模板套用。模板连接:http://blog.youkuaiyun.com/keshuai19940722/article/details/10087993int main() { char str1[N], str2[N]; bign num1, num2, sum;原创 2013-08-20 00:01:30 · 1197 阅读 · 0 评论 -
hdu 1047 Integer Inquiry(高精度加法)
题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=1047题目大意:给出测试组数,每组之间有空行,结束为“0”, 求每组给出的数字之和,输出每两组之间空行。解题思路:处理一下空行就可以了,‘+’法套模板。模板连接:http://blog.youkuaiyun.com/keshuai19940722/article/detail原创 2013-08-20 09:32:07 · 1075 阅读 · 0 评论 -
hdu 5429 Geometric Progression(高精度)
题目链接:hdu 5429 Geometric Progression解题思路高精度判断等比,注意全0也是等比。代码#include <cstdio>#include <cstring>#include <iostream>using namespace std;const int maxn = 10005;struct bign { int len, num[maxn]; bi原创 2015-10-11 21:26:55 · 555 阅读 · 0 评论