Mod Tree(hdu2815)】的更多相关文章

Mod Tree Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 5934    Accepted Submission(s): 1498 Problem Description   The picture indicates a tree, every node has 2 children.  The depth of the nod…
Mod Tree Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 96 Accepted Submission(s): 38   Problem Description   The picture indicates a tree, every node has 2 children.  The depth of the nodes whos…
Problem Description   The picture indicates a tree, every node has 2 children.  The depth of the nodes whose color is blue is 3; the depth of the node whose color is pink is 0.  Now out problem is so easy, give you a tree that every nodes have K chil…
联系:http://acm.hdu.edu.cn/showproblem.php?pid=2815 意甲冠军: watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvb29vb29vb29l/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt=""> 思路:与上题不同.这道题不要求m是素数.是利用扩展Baby Step Giant S…
http://acm.hdu.edu.cn/showproblem.php?pid=2815 //解 K^D ≡ N mod P #include<map> #include<cmath> #include<cstdio> #include<iostream> using namespace std; map<int,int>mp; typedef long long LL; void read(int &x) { x=; char c=…
题目链接 直接用模板好了.实在不行,反正有队友啊~~~~ #include<bits/stdc++.h> using namespace std; typedef long long LL; map<LL,LL>mp; LL qpow(LL x,LL n,LL mod) //求x^n%mod { LL ret=; ) { ) ret=ret*x%mod; x=x*x%mod; } return ret; } LL gcd(LL a, LL b) { return b? gcd(b,…
Accepted 406MS 8576K 2379 B C++/** 这里加了一点限制,,大体还是一样的,, **/ #include <iostream> #include <cstdio> #include <cmath> #include <cstring> #include <algorithm> using namespace std; long long a,b,n; ; bool Hash[maxn]; long long val[…
不会,先搁着…… http://blog.csdn.net/acm_cxlove/article/details/7832197…
传送门:https://acm.ecnu.edu.cn/contest/105/problem/Q/ 一棵树,支持两种操作:给一条路径上的节点加上一个等差数列;求两点路径上节点和. 很明显,熟练剖分.用线段树维护链上的区间和,每个节点中记录等差数列的首项,公差和区间和.因为两个等差数列叠加之后还是等差数列,所以将首项与公差视作懒惰标记. 因为在寻找LCA的过程中,u往上跳的时候,其实是要维护递减的等差数列(dfs序是u->topu递减,而数列是u->topu递增);v往上跳的时候,是递增的.计…
题目传送门 题目描述:给出一颗树,每条边都有权值,然后列出一个n的全排列,对于所有的全排列,比如1 2 3 4这样一个排列,要算出1到2的树上距离加2到3的树上距离加3到4的树上距离,这个和就是一个排列的val,计算所有全排列的val和就可以了. 思路:对于一个n的全排列,会发现 任意x-y的边在这个全排列中出现的次数是一样的,(x-y和y到x是不一样的边).也就是说我只需要计算出这个次数,然后再乘以所有边的总和(所有x-y和y-x的和)就可以了. 次数就是 ,(边的总数除以边的种类)化简一下就…