http://acm.hdu.edu.cn/showproblem.php?pid=1071 解一个给定三个点的坐标二次函数某区域的积分值. 设出方程之后高斯消元得到二次函数.然后再消元得到直线. 两次积分然后相减就可以了. 把自适应辛普森改成了传入函数指针的形式,有点多此一举. 可以这样做的原因,是因为这道题保证要求的区域都是在第一象限,否则不能直接定积分. 语言:G++ #include<bits/stdc++.h> using namespace std; typedef long lo
Computer Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 34390 Accepted Submission(s): 5383 Problem Description A school bought the first computer some time ago(so this computer's id is 1). D
假设以u为根时结果是tot,现在转换到了以u的儿子v为根,那么结果变成了tot-size[v]+(sizetot-size[v]) 根据这个转移方程,先求出以1为根的tot,然后dfs一次转移即可 #include<iostream> #include<cstring> #include<cstdio> #include<algorithm> using namespace std; #define ll long long #define N 200005
周末牛客挂了个更难的,这个简单一些 #include<iostream> #include<cstring> #include<cstdio> #include<algorithm> #include<vector> #define maxn 200100 using namespace std; typedef long long ll; struct Node { int p; int len; Node(int a, int b) :p(a