Luogu4546 THUWC2017 在美妙的数学王国中畅游 LCT、泰勒展开
题意:反正就是一堆操作
LCT总是和玄学东西放在一起
我们不妨令$x_0=0.5$(其实取什么都是一样的,但是最好取在$[0,1]$的范围内),将其代入给出的式子,我们得到的$f(x)$的式子就是一个多项式了。
然后复习一下导数:
$(Cf(x))'=Cf'(x)$($C$为常数)
$sin'(x)=cos(x),cos'(x)=-sin(x),(e^x)'=e^x,C'=0 , (ax+b)'=a$
令$g(x)=u$,则$f[g(x)]' = f'(u) \times g'(x)$
有了这些式子就可以得到给出的三种函数的任意阶导数了。
但是显然我们不能把所有项的系数都算出来。因为在比较靠后的项中,阶乘的值很大,对答案造成的贡献就会小到忽略不计,所以我们可以取前面若干项,这里我取的是前$12$项。
然后用$LCT$维护这些项的系数和,每一次询问把链拿出来直接算就行了,难题变成裸题了qwq
#include<bits/stdc++.h>
#define ld long double
//This code is written by Itst
using namespace std;
inline int read(){
;
;
char c = getchar();
while(c != EOF && !isdigit(c)){
if(c == '-')
f = ;
c = getchar();
}
while(c != EOF && isdigit(c)){
a = (a << ) + (a << ) + (c ^ ');
c = getchar();
}
return f ? -a : a;
}
;
struct node{
ld point[] , pre[] , a , b;
] , fa , type;
bool mark;
}Tree[MAXN];
int N;
];
inline bool nroot(int x){
] == x || Tree[Tree[x].fa].ch[] == x;
}
inline bool son(int x){
] == x;
}
inline ld calc(int type , int n , ld a , ld b){
ld sum = ;
switch(type){
:
){
:
sum = sin(0.5 * a + b);
break;
:
sum = cos(0.5 * a + b);
break;
:
sum = -sin(0.5 * a + b);
break;
:
sum = -cos(0.5 * a + b);
break;
}
return sum * pow(a , n);
:
return pow(a , n) * exp(a * 0.5 + b);
:
switch(n){
:
return a * 0.5 + b;
:
return a;
default:
;
}
}
}
inline void pushup(int x){
; i <= ; ++i)
Tree[x].point[i] = Tree[x].pre[i] + Tree[Tree[x].ch[]].point[i] + Tree[Tree[x].ch[]].point[i];
}
inline void getpre(int x){
; i <= ; ++i)
Tree[x].pre[i] = calc(Tree[x].type , i , Tree[x].a , Tree[x].b);
}
inline void ZigZag(int x){
bool f = son(x);
];
if(nroot(y))
Tree[z].ch[son(y)] = x;
Tree[x].fa = z;
Tree[x].ch[f ^ ] = y;
Tree[y].fa = x;
Tree[y].ch[f] = w;
if(w)
Tree[w].fa = y;
pushup(y);
pushup(x);
}
inline void pushdown(int x){
if(Tree[x].mark){
Tree[Tree[x].ch[]].mark ^= ;
Tree[Tree[x].ch[]].mark ^= ;
Tree[x].mark = ;
swap(Tree[x].ch[] , Tree[x].ch[]);
}
}
void pushdown_all(int x){
if(nroot(x))
pushdown_all(Tree[x].fa);
pushdown(x);
}
inline void Splay(int x){
pushdown_all(x);
while(nroot(x)){
if(nroot(Tree[x].fa))
ZigZag(son(x) == son(Tree[x].fa) ? Tree[x].fa : x);
ZigZag(x);
}
}
inline void access(int x){
; x ; y = x , x = Tree[x].fa){
Splay(x);
Tree[x].ch[] = y;
pushup(x);
}
}
inline int findroot(int x){
access(x);
Splay(x);
pushdown(x);
])
pushdown(x = Tree[x].ch[]);
Splay(x);
return x;
}
inline void makeroot(int x){
access(x);
Splay(x);
Tree[x].mark ^= ;
}
inline void split(int x , int y){
makeroot(x);
access(y);
Splay(y);
}
inline void link(int x , int y){
makeroot(x);
Tree[x].fa = y;
}
inline void cut(int x , int y){
split(x , y);
Tree[y].ch[] = Tree[x].fa = ;
pushup(y);
}
inline void change(int x , int type , ld a , ld b){
access(x);
Splay(x);
Tree[x].type = type;
Tree[x].a = a;
Tree[x].b = b;
getpre(x);
pushup(x);
}
int main(){
freopen("4546.in" , "r" , stdin);
freopen("4546.out" , "w" , stdout);
N = read();
int M = read();
read();
; i <= N ; ++i){
Tree[i].type = read();
scanf("%Lf %Lf" , &Tree[i].a , &Tree[i].b);
getpre(i);
}
while(M--){
ld a , b , times , jc;
int d , e;
if(scanf("%s" , s) == EOF)
;
]){
case 'a':
d = read() + ;
e = read() + ;
link(d , e);
break;
case 'd':
d = read() + ;
e = read() + ;
cut(d , e);
break;
case 'm':
d = read() + ;
e = read();
scanf("%Lf %Lf" , &a , &b);
change(d , e , a , b);
break;
case 't':
d = read() + ;
e = read() + ;
scanf("%Lf" , &a);
if(findroot(d) != findroot(e))
puts("unreachable");
else{
split(d , e);
b = ;
times = jc = ;
a -= 0.5;
; i <= ; ++i){
b += times * Tree[e].point[i] / jc;
times *= a;
jc *= (i + );
}
printf("%.9Lf\n" , b);
}
}
}
;
}
Luogu4546 THUWC2017 在美妙的数学王国中畅游 LCT、泰勒展开的更多相关文章
- [THUWC2017]在美妙的数学王国中畅游 LCT+泰勒展开+求导
p.s. 复合函数求导时千万不能先带值,再求导. 一定要先将符合函数按照求导的规则展开,再带值. 设 $f(x)=g(h(x))$,则对 $f(x)$ 求导: $f'(x)=h'(x)g'(h(x)) ...
- [BZOJ5020][THUWC2017]在美妙的数学王国中畅游(LCT)
5020: [THUWC 2017]在美妙的数学王国中畅游 Time Limit: 80 Sec Memory Limit: 512 MBSec Special JudgeSubmit: 323 ...
- 【BZOJ5020】[LOJ2289]【THUWC2017】在美妙的数学王国中畅游 - LCT+泰勒展开
咕咕咕?咕咕咕! 题意: Description 数字和数学规律主宰着这个世界. 机器的运转, 生命的消长, 宇宙的进程, 这些神秘而又美妙的过程无不可以用数学的语言展现出来. 这印证了一句古老的名言 ...
- BZOJ5020: [THUWC 2017]在美妙的数学王国中畅游(LCT,泰勒展开,二项式定理)
Description 数字和数学规律主宰着这个世界. 机器的运转, 生命的消长, 宇宙的进程, 这些神秘而又美妙的过程无不可以用数学的语言展现出来. 这印证了一句古老的名言: ...
- 【BZOJ5020】【THUWC2017】在美妙的数学王国中畅游 LCT 泰勒展开
题目大意 给你一棵树,每个点有一个函数\(f(x)\) 正弦函数 \(\sin(ax+b) (a\in[0,1],b\in[0,\pi],a+b\in[0,\pi])\) 指数函数 \(e^{ax+b ...
- 洛谷P4546 [THUWC2017]在美妙的数学王国中畅游 [LCT,泰勒展开]
传送门 毒瘤出题人卡精度-- 思路 看到森林里加边删边,容易想到LCT. 然而LCT上似乎很难实现往一条链里代一个数进去求和,怎么办呢? 善良的出题人在下方给了提示:把奇怪的函数泰勒展开搞成多项式,就 ...
- [THUWC2017][bzoj5020] 在美妙的数学王国中畅游 [LCT+泰勒展开]
题面 LOJ传送门 思路 这里很重要 它提示我们,把给定的三个函数泰勒展开,并用LCT维护每一项泰勒展开式的值,维护十几项就满足了题目的精度要求 我们考虑一个函数在0位置的泰勒展开 $f(x)=\su ...
- 「LOJ 2289」「THUWC 2017」在美妙的数学王国中畅游——LCT&泰勒展开
题目大意: 传送门 给一个动态树,每个节点上维护一个函数为$f(x)=sin(ax+b)$.$f(x)=e^{ax+b}$.$f(x)=ax+b$中的一个. 支持删边连边,修改节点上函数的操作. 每次 ...
- bzoj 5020(洛谷4546) [THUWC 2017]在美妙的数学王国中畅游——LCT+泰勒展开
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=5020 https://www.luogu.org/problemnew/show/P4546 ...
随机推荐
- layer插件layer.photos()动态插入的图片无法正常显示
layer插件layer.photos()动态插入的图片无法正常显示,点击后面插入的图片,显示的是之前的图片列表,再次点击又是正常 有朋友遇到同样的问题 http://fly.layui.com/ji ...
- 安卓开发_浅谈Fragment之事务添加Fragment对象
我们都知道给一个activity动态添加fragment的时候 有下面几种添加方式 看一下布局文件 <LinearLayout xmlns:android="http://schema ...
- IDEA报错: Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'spring.datasource.url' in value "${spring.datasource.url}"
运行审核流模块: 在ActivitiServiceApplication模块日志报错: Error starting ApplicationContext. To display the auto-c ...
- ViewPager+Fragment切换卡顿解决办法
1.ViewPager设置预加载 我有4个tag,都不想被销毁,设置预加载个数为3. ViewPager viewPager; viewPager.setOffscreenPageLimit(3); ...
- Python 会是我们的未来吗?
Python 热度激增 根据 Stack Overflow 的一项调查显示,Python 不仅在专业领域的使用率得到增长,在普通开发上的使用率也有所提升,有 40% 的受访者表示他们现在正在使用 Py ...
- Centos7下搭建SVN服务,本地提交代码自动同步到WEB目录
1.安装SVN服务[root@bogon ~]# yum -y install subversion 2.查看svnserve安装目录[root@bogon ~]# whereis svnserves ...
- 代理ARP--善意的欺骗
1. 代理ARP(Proxy ARP)是什么? 顾名思义,它指通过中间设备(通常为Router)代替其他主机响应ARP请求.对于没有配置默认网关的主机想要与其他网络的另一台主机通信时,网关收到源主机的 ...
- js判断元素是否是disable状态
js判断元素是否是disable状态 jquery判断元素状态用$(select).prop(属性值) == true js判断button是否可以点击: //判断button是否为不可点击状态 if ...
- Win10 + MASM32 + EditPlus 汇编语言编程环境设置
下载安装MASM32汇编环境 官方下载站:MASM32 环境变量配置 配置MasmHome变量,值为masm32的安装目录: 配置include和lib变量 include : %MasmHome%\ ...
- python之列表的常用操作
Python list 常用方法总结 一,创建列表 只要把逗号分隔的不同的数据项使用方括号([ ])括起来即可 下标(角标,索引)从0开始,最后一个元素的下标可以写-1 list = ['1 ...