上一页 1 ··· 4 5 6 7 8 9 10 11 12 13 下一页
摘要: 代码: #include<iostream> #include<stdio.h> #include<string.h> using namespace std; const int maxn = 1005; int dp[maxn][maxn]; int main(){ char s1[maxn], 阅读全文
posted @ 2020-02-26 22:31 sqsq 阅读(103) 评论(0) 推荐(0) 编辑
摘要: 代码: #include<iostream> #include<stdio.h> using namespace std; const int maxn = 1001; int a[maxn],dp[maxn]; int main(){ int n; cin>>n; for(int i=1;i<=n 阅读全文
posted @ 2020-02-26 17:49 sqsq 阅读(80) 评论(0) 推荐(0) 编辑
摘要: 求C(n,m)%p; 概念: 组合数我们用C(n,m)表示,它代表在n个数中取m个数的方案。(这个概念主要用于将问题抽象到组合数上)。 公式: 1、C(n,m)=C(n,n-m); 2、C(n,m)=C(n-1,m-1)+C(n-1,m); 3、C(0,n)+C(1,n)+C(2,n)+C(3,n) 阅读全文
posted @ 2020-02-24 21:24 sqsq 阅读(752) 评论(0) 推荐(0) 编辑
摘要: 注意: 有的时候memset会出问题 思路: i代表A,j代表B,题目要求n个AB,m个BA,所以在一个字符串中,前n个A贡献给AB中的A,前m个B贡献给BA中的B,这里用到贪心的思想 所以当i<=n时,直接用于贡献给AB中的A,当i>n时,i-n个A用来组成BA,因此当j>i-n时,此时可以放A组 阅读全文
posted @ 2020-02-23 23:34 sqsq 阅读(105) 评论(0) 推荐(0) 编辑
摘要: 思想: 线性基和快速幂 代码: #include<iostream> #include<stdio.h> #include<cstring> #include<vector> using namespace std; typedef long long ll; const int mod = 1e9 阅读全文
posted @ 2020-02-22 15:49 sqsq 阅读(152) 评论(0) 推荐(0) 编辑
摘要: 代码: 方法一: 这个是根据完全背包的思路来做,但是加了对个数的限制。 #include<iostream> #include<stdio.h> #include<string.h> using namespace std; const int maxn = 1e5+10; int dp[maxn] 阅读全文
posted @ 2020-02-21 14:54 sqsq 阅读(137) 评论(0) 推荐(0) 编辑
摘要: 代码: #include<iostream> #include<stdio.h> using namespace std; typedef long long ll; const int inf = 0x3f3f3f; int main(){ int t; cin>>t; while(t--){ i 阅读全文
posted @ 2020-02-20 22:24 sqsq 阅读(130) 评论(0) 推荐(0) 编辑
摘要: 代码: 错误代码:超空间:由于定义了一个二维的dp数组,然后超了,所以我们要把二维转换为一维 #include<iostream> #include<stdio.h> #include<string.h> using namespace std; const int maxn = 3500; int 阅读全文
posted @ 2020-02-20 17:55 sqsq 阅读(143) 评论(0) 推荐(0) 编辑
摘要: 代码: #include<iostream> #include<stdio.h> using namespace std; typedef long long ll; int a[20]; ll dp[20][2]; //if6:当前为是否为6;limit:上一位是否是上界 ll dfs(int l 阅读全文
posted @ 2020-02-18 21:38 sqsq 阅读(88) 评论(0) 推荐(0) 编辑
摘要: F maki和tree 思路: 用到并查集的思想 如图: 简单路径上只有一个黑色点的方案:第一种端点有一个为黑色点,第二种两端点均为白色点,端点连接的线路中有一个黑色点 ans = (1+2+3)+1*2+2*3+1*3 = (1+2+3)+1*(2+3)+2*3 代码: #include<iost 阅读全文
posted @ 2020-02-17 23:13 sqsq 阅读(168) 评论(0) 推荐(0) 编辑
上一页 1 ··· 4 5 6 7 8 9 10 11 12 13 下一页