玄学MTL

P1464 Function

呃是MLE
by FZzzz @ 2019-02-23 17:37:29


所以MTL是什么?
by zhanghengrui @ 2019-02-23 17:37:32


MTL好评
by 豌豆射手皮0608 @ 2019-02-23 17:38:25


@[zhanghengrui](/space/show?uid=110634) 百度了一下是矩阵模板库QwQ
by t162 @ 2019-02-23 17:38:44


@[stable_sort](/space/show?uid=174045) 帮你改了一下 ```cpp #include<iostream> #include<cstring> #include<cstdio> #define a x #define b y #define c z //#define LOCAL using namespace std; long long w[25][25][25]; long long f(long long x,long long y,long long z){ if(x<=0||y<=0||z<=0) return 1; if(x>20||y>20||z>20) return f(20,20,20); if(w[x][y][z]>0) return w[x][y][z]; if(a<b&&b<c) w[x][y][z]=f(a,b,c-1)+f(a,b-1,c-1)-f(a,b-1,c); else w[x][y][z]=f(a-1,b,c)+f(a-1,b-1,c)+f(a-1,b,c-1)-f(a-1,b-1,c-1); return w[x][y][z]; } int main() { memset(w,-1,sizeof(w)); int a,b,c; while(cin>>a>>b>>c){ if(a==-1&&b==-1&&c==-1) break; cout<<"w("<<a<<", "<<b<<", "<<c<<") = "<<f(a,b,c)<<endl; } return 0; } ```
by Smile_Cindy @ 2019-02-23 18:10:56


@[Alpha](/space/show?uid=87058) 过了谢谢大佬,但是这是什么原理呢?
by FZzzz @ 2019-02-23 20:46:06


@[stable_sort](/space/show?uid=174045) 你的a,b,c和x,y,z混淆了,我只不过是把他们重新统一一下而已。
by Smile_Cindy @ 2019-02-23 20:48:37


@[Alpha](/space/show?uid=87058) 哦哦哦是这一段吧 ``` if(a<b&&b<c) w[x][y][z]=f(a,b,c-1)+f(a,b-1,c-1)-f(a,b-1,c); else w[x][y][z]=f(a-1,b,c)+f(a-1,b-1,c)+f(a-1,b,c-1)-f(a-1,b-1,c-1); ```
by FZzzz @ 2019-02-23 20:53:12


@[Alpha](/space/show?uid=87058) 谢谢大佬
by FZzzz @ 2019-02-23 20:53:33


|