随笔分类 - 题 / 算法 / dp
摘要:#include<bits/stdc++.h> using namespace std; namespace IO { char buf[50]; } inline void qr(int &x){char ch=getchar(),lst=' ';while(ch>'9'||ch<'0')lst=
阅读全文
摘要:又角果,唐 #include<bits/stdc++.h> using namespace std; const int inf=0x3f3f3f3f; int n,ans=-inf; int a[105]; int f[150][150],g[150][150]; char c[105]; int
阅读全文
摘要:题解 #include<bits/stdc++.h> using namespace std; struct edge { int to,nxt; } e[1000010<<1]; int n,cnt,id; int head[1000010]; long long ans; long long f
阅读全文
摘要:#include<bits/stdc++.h> using namespace std; int p,q,dp[15][15],a[15]; void init() { for(int i=0;i<=9;i++) dp[1][i]=1; for(int i=2;i<=10;i++)for(int j
阅读全文
摘要:sb大括号,卡我114514ms #include <bits/stdc++.h> using namespace std; const int maxn=100005,maxk=104,mod=1000000007; int f[maxn][maxk][2][2]; int g[maxk][2][
阅读全文
摘要:#include<bits/stdc++.h> using namespace std; inline int read(){int x=0;bool f=0;char ch=getchar();while (ch<'0'||ch>'9'){if (ch=='-') f=1;ch=getchar()
阅读全文
摘要:这题治好了我的快读恐惧症,让我理解了cin的力量 cin,照亮世界! #include<bits/stdc++.h> using namespace std; const int inf=0x3f3f3f3f; int n,ans=-inf; int a[105]; int f[150][150],
阅读全文
摘要:怎么这么多忘交的 一起发的原因还是vjudge #include<bits/stdc++.h> using namespace std; int read() { int x = 0; bool op = 0; char c = getchar(); while(!isdigit(c))op |=
阅读全文
摘要:区间dp。 转移方程见题解(doge) #include<bits/stdc++.h> using namespace std; int m[310],dp[310][310],ans; int main() { ios::sync_with_stdio(0); cin.tie(NULL); cou
阅读全文
摘要:模板区间dp. 懒癌,于是把石子合并copy了一下。 #include<bits/stdc++.h> using namespace std; int m[310],dp[310][310],anss,ans; int main() { ios::sync_with_stdio(0); cin.ti
阅读全文
摘要:简单四维dp。 #include<bits/stdc++.h> using namespace std; int a[355],b,t[5],dp[45][45][45][45]; int main(){ ios::sync_with_stdio(0); cin.tie(NULL); cout.ti
阅读全文
摘要:补交。 #include<iostream> #include<cstdio> using namespace std; int g[105],f[105],a[105],s[105]; int main(){ int n; cin>>n; for(int i=1;i<=n;i++){ cin>>a
阅读全文
摘要:4维dp(因为n<=10) 就是二维dp+判断是否重复取 #include<bits/stdc++.h> using namespace std; int dp[15][15][15][15],a[15][15],x,y,z; int main() { ios::sync_with_stdio(0)
阅读全文
摘要:小粉兔的楼下 #include<bits/stdc++.h> using namespace std; long long N,Ans=1; long long C,G[50]; long long qPow(long long b,long long e) { long long A=1; for
阅读全文
摘要:#include <bits/stdc++.h> using namespace std; int num[12],len; long long l,r,dp[11][11][11][2][2][2][2]; long long f(int p,int a,int b,bool c,bool d,b
阅读全文
摘要:新鲜出炉的数位dp #include<bits/stdc++.h> using namespace std; long long a,b; long long ten[20],f[20]; long long cnta[20],cntb[20]; void solve(long long x,lon
阅读全文
摘要:以下内容摘自OI-Wiki 引子 数位dp是指把一个数字按照个、十、百、千等等一位一位地拆开,关注它每一位上的数字。如果拆的是十进制数,那么每一位数字都是 0~9,其他进制可类比十进制。 数位 DP:用来解决一类特定问题,这种问题比较好辨认,一般具有这几个特征: 要求统计满足一定条件的数的数量(即,
阅读全文
摘要:( •̀ ω •́ )y 好fan 题解 #include <bits/stdc++.h> using namespace std; inline int read(){ char c;int f=1,res=0; while(c=getchar(),!isdigit(c))if(c=='-')f*
阅读全文
摘要:高效高效 分块。 here #include<bits/stdc++.h> using namespace std; int n,a[500010]; double dp[500010],sqr[500010]; double w(int j,int i) { return double(a[j])
阅读全文
摘要:这个故事告诉我们,要全心全意赞美太阳。 题解 #include<bits/stdc++.h> using namespace std; const unsigned long long mod=998244353; struct data { int dp[3][3]; inline int* op
阅读全文