- 博客(28)
- 收藏
- 关注
原创 【HDU - 5452 】Minimum Cut (树上差分)
Given a simple unweighted graph G (an undirected graph containing no loops nor multiple edges) with n nodes and m edges. Let T be a spanning tree of G. We say that a cut in G respects T if it cuts j...
2018-08-30 16:37:36 289
原创 【HDU 5528】Count a * b(推导)
Problem Description Marry likes to count the number of ways to choose two non-negative integers a and b less than m to makea×ba×b a×b mod m≠0m≠0m≠0.Let’s denotef(m)f(m) f(m) as the number of ways ...
2018-08-29 17:32:48 833
原创 【51nod】Gcd and Phi(反演)
基准时间限制:2 秒 空间限制:131072 KB 分值: 320 F(n)=∑ni=1∑nj=1ϕ(ϕi,ϕj)F(n)=∑i=1n∑j=1nϕ(ϕi,ϕj) F(n)=∑_{i=1}^n∑_{j=1}^nϕ(ϕ_i,ϕ_j) 其中 ϕ 表示欧拉函数。欧拉函数ϕn 是不超过n的数中与n互质的数的数目。 ϕ(ϕi,ϕj) 表示i,j欧拉函数值的最大公约数的欧拉函数值.给出n,求F(n...
2018-08-28 21:23:04 399
原创 【51nod】 寻找分数(数学)
基准时间限制:1 秒 空间限制:131072 KB 分值: 160 给出 a,b,c,d, 找一个分数p/q,使得a/b < p/q < c/d,并且q最小。例如:1/3同1/2之间,符合条件且分母最小的分数是2/5。(如果q相同,输出p最小的) Input 第1行:一个数T,表示后面用作输入测试的数的数量。(1 <= T <= 10000) 第2 - T + 1行...
2018-08-28 17:58:07 434
原创 【51nod】最大公约数之和(简单数论或者积性)
给出一个n,求1-n这n个数,同n的最大公约数的和。比如:n = 6 1,2,3,4,5,6 同6的最大公约数分别为1,2,3,2,1,6,加在一起 = 15 Input 1个数N(N &amp;lt;= 10^9) Output 公约数之和 Input示例 6 Output示例 15 思路:先转化成数学公式: ans=∑i=1ngcd(i,n)ans=∑i=1ngcd(i,n)an...
2018-08-28 15:28:16 703
原创 【51nod】最复杂的数 (简单搜索)
基准时间限制:1 秒 空间限制:131072 KB 分值: 40 把一个数的约数个数定义为该数的复杂程度,给出一个n,求1-n中复杂程度最高的那个数。 例如:12的约数为:1 2 3 4 6 12,共6个数,所以12的复杂程度是6。如果有多个数复杂度相等,输出最小的。 Input 第1行:一个数T,表示后面用作输入测试的数的数量。(1 <= T <= 100) 第2 - T ...
2018-08-28 13:19:36 402
原创 【2018 Multi-University Training Contest 10】Calculate(莫比乌斯反演)
Problem Description Given A, B, C, Calculate Where φ(n) denotes the number of positive integers ≤ n that are relatively prime to n.Input The first line of the input contains an integer T , deno...
2018-08-24 18:59:17 285
原创 【ZOJ - 2116】Christopher's Christmas Letter(Lucas)
Dashing thro’ the snow, In a one-horse open sleigh, O’er the fields we go, Laughing all the way; Bells on bobtail ring, Making spirits bright; What fun it is to ride and sing A sleighing song t...
2018-08-24 14:19:56 213
原创 【bzoj1284】树的计树(组合数学+prufer数列)
一个有n个结点的树,设它的结点分别为v1, v2, …, vn,已知第i个结点vi的度数为di,问满足这样的条件的不同的树有多少棵。给定n,d1, d2, …, dn,编程需要输出满足d(vi)=di的树的个数。Input 第一行是一个正整数n,表示树有n个结点。第二行有n个数,第i个数表示di,即树的第i个结点的度数。其中1<=n<=150,输入数据保证满足条件的树不超过10^...
2018-08-23 16:15:44 737
原创 【HRBUST - 1284 】编辑距离(简单dp)
俄罗斯科学家Vladimir Levenshtein在1965年提出了编辑距离概念。编辑距离,又称Levenshtein距离,是指两个字符串之间,由一个转成另一个所需的最少编辑操作次数。许可的三种编辑操作包括插入一个字符、删除一个字符、将一个字符替换成另一个字符。 至今,编辑距离一直在相似句子检索的领域中发挥着不可忽视的作用。我们不妨来设计一个程序,计算两个字符串的编辑距离。Input...
2018-08-23 15:18:27 328
原创 二项式反演
我们给定两个函数F(x)F(x)F(x)和f(x)f(x)f(x),定义域在非负整数上。 若存在如下给定关系: F(n)=∑i=0n(−1)iCinf(i)F(n)=∑i=0n(−1)iCnif(i)F(n)=\sum_{i=0}^n(-1)^iC_n^if(i) 则有:f(n)=∑i=0n(−1)iCinF(i)f(n)=∑i=0n(−1)iCniF(i)f(n)=\sum_{i=0}^n...
2018-08-22 21:49:44 1310
原创 【CodeForces - 622F 】The Sum of the k-th Powers (拉格朗日插值)
Examples Input 4 1 Output 10 Input 4 2 Output 30 Input 4 3 Output 100 Input 4 0 Output 4 这个就直接上我的模板就可以了.#include&lt;iostream&gt;#include&lt;cstdio&gt;#include&lt;cmath&gt;#defi...
2018-08-21 15:32:01 396
原创 求解n次函数多项式之拉格朗日插值
设F(x)=a0+a1x+a2x2+...+anxnF(x)=a0+a1x+a2x2+...+anxnF(x)=a_0+a_1x+a_2x^2+...+a_nx^n在一些题目中例如找规律,比如是我上次在区域赛的时候如果可以真名或者猜出一些式子是多项式,还有次数,那么我用的待定系数法,就可以解方程来做了。 可以直接手动解,但是也可以借助程序了。 这里就用到了一个东西叫拉格朗日插值法。 假如...
2018-08-21 10:44:15 7162
原创 【HDU-5000】Clone(dp)
Problem Description After eating food from Chernobyl, DRD got a super power: he could clone himself right now! He used this power for several times. He found out that this power was not as perfect as...
2018-08-16 20:29:09 216
原创 【HDU 5917】Instability(ramsey定理)
Long long ago, there was a prosperous kingdom which consisted of n cities and every two cites were connected by an undirected road.However, one day a big monster attacked the kingdom and some roads ...
2018-08-16 19:43:12 231
原创 【51nod】猪和回文
一只猪走进了一个森林。很凑巧的是,这个森林的形状是长方形的,有n行,m列组成。我们把这个长方形的行从上到下标记为1到n,列从左到右标记为1到m。处于第r行第c列的格子用(r,c)表示。刚开始的时候猪站在(1,1),他的目标是走到(n,m)。由于猪回家心切,他在(r,c)的时候,只会往(r+1,c)或(r,c+1)走。他不能走出这个森林。这只猪所在的森林是一个非同寻常的森林。有一些格子看起来...
2018-08-16 18:28:10 220
原创 【51nod】AVL树的种类
平衡二叉树(AVL树),是指左右子树高度差至多为1的二叉树,并且该树的左右两个子树也均为AVL树。 现在问题来了,给定AVL树的节点个数n,求有多少种形态的AVL树恰好有n个节点。 Input 一行,包含一个整数n。 (0 < n <= 2000) Output 一行表示结果,由于结果巨大,输出它对1000000007取余数的结果。 Input示例 10 Output示例...
2018-08-16 15:36:03 412
原创 【Timus 1132】 Square Root(二次同余)
上代码:#include&lt;iostream&gt;#include&lt;cstdio&gt;#include&lt;cmath&gt;#include&lt;algorithm&gt;#define ll long longusing namespace std;ll P(ll a,ll b,ll mod){ ll ans=1; w
2018-08-14 17:34:13 452
原创 计算模m的k次根
已知:k,b,mk,b,mk,b,m 求解同余式:xk≡b(mod m)xk≡b(mod m)x^k\equiv b(mod\ m)如果我们满足两个限制 1.gcd(b,m)=1gcd(b,m)=1gcd(b,m)=1 2.gcd(k,ϕ(m))=1gcd(k,ϕ(m))=1gcd(k,\phi(m))=1 那么我们是有快速的方法求解x的1.先计算ϕ(m)ϕ(m...
2018-08-14 10:48:43 434
原创 【2018 Multi-University Training Contest 7】Sequence(分块+矩阵快速幂)
Problem Description Let us define a sequence as below⎧⎩⎨⎪⎪⎪⎪⎪⎪F1F2Fn===ABC⋅Fn−2+D⋅Fn−1+⌊Pn⌋Your job is simple, for each task, you should output Fn module 109+7.Input The first line has only on...
2018-08-13 21:56:27 238
原创 【2018 Multi-University Training Contest 7】GuGuFishtion(莫比乌斯反演)
Problem Description题目链接 Today XianYu is too busy with his homework, but the boring GuGu is still disturbing him!!!!!! At the break time, an evil idea arises in XianYu’s mind. ‘Come on, you xxxxxxx ...
2018-08-13 18:05:47 414
原创 【2018 Multi-University Training Contest 6】bookshelf(莫比乌斯反演)
Problem Description Patrick Star bought a bookshelf, he named it ZYG !! Patrick Star has N book .The ZYG has K layers (count from 1 to K) and there is no limit on the capacity of each layer !No...
2018-08-12 20:31:45 222
原创 【wanaflyCamp】Steins;Gate(原根+FFT)
利用原根吧乘运算变成加运算,然后fft,但是不知道为什么就是过不去啊。。。 先把有问题的代码先贴一下,过会在调试一下: 代码:#include&amp;amp;lt;iostream&amp;amp;gt;#include&amp;amp;lt;cstdio&amp;amp;gt;#include&amp;amp;lt;cmath&amp;amp;gt;#define maxx 200005
2018-08-10 11:40:58 499 1
原创 【HDU - 4609 】3-idiots(FFT)
King OMeGa catched three men who had been streaking in the street. Looking as idiots though, the three men insisted that it was a kind of performance art, and begged the king to free them. Out of hatr...
2018-08-08 10:57:46 232
原创 【wanaflyCamp】平衡二叉树(dp)
题目描述平衡二叉树,顾名思义就是一棵“平衡”的二叉树。在这道题中,“平衡”的定义为,对于树中任意一个节点,都满足左右子树的高度差不超过 . 空树的高度定义为0,单个节点的高度为1,其他情况下树的高度定义为根节点左右子树高度最大值 + 1。 一棵在高度上平衡的树,节点数可能不平衡。再定义一棵树的不平衡度为这棵树中所有节点的左右子树的节点数之差的最大值。 给定平衡的定义参数, 你需要求出所有高...
2018-08-07 17:26:32 667
原创 【51nod 1135】原根
设m是正整数,a是整数,若a模m的阶等于φ(m),则称a为模m的一个原根。(其中φ(m)表示m的欧拉函数) 给出1个质数P,找出P最小的原根。 Input 输入1个质数P(3 <= P <= 10^9) Output 输出P最小的原根。 Input示例 3 Output示例 2问题解决的是如何求一个质数的原根。,原根的定义我在之前的一篇文章写过,这里来讲是如何实现...
2018-08-07 12:00:39 195
原创 【wanaflyCamp】Growth(dp)
题目描述弱弱有两个属性a和b,这两个属性初始的时候均为0,每一天他可以通过努力,让a涨1点或b涨1点。 为了激励弱弱努力学习,我们共有n种奖励,第i种奖励有xi,yi,zi三种属性,若a ≥ xi且b ≥ yi,则弱弱在接下来的每一天都可以得到zi的分数。 问m天以后弱弱最多能得到多少分数。 输入第一行一个两个整数n和m(1 ≤ n ≤ 1000,1 ≤ m ≤ 2000000...
2018-08-06 16:25:48 343
原创 【wanaflyCamp】电音之王
代码: 学会了新姿势,以前只会longnlongnlongn的快速乘,无限T…后来想起我原来很久以前其实是学过的。#include&lt;iostream&gt;#include&lt;cstdio&gt;#define ll long long#define LL long longusing namespace std;inline LL mul(LL x,LL y,L...
2018-08-06 10:20:32 592
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人