随笔 - 531  文章 - 0  评论 - 3  阅读 - 10215 

随笔分类 -  杂题

uva 11078
摘要:shui题 #include <iostream> #include <cstring> #include <algorithm> #include <cmath> using namespace std; const int N=1e5+5; int a[N]; int n,m; void sol 阅读全文
posted @ 2022-10-26 16:54 towboat 阅读(4) 评论(0) 推荐(0) 编辑
uva11384
摘要:对1 , 2, ,3, ...n 这个序列操作最少的次数,序列元素都为0 又到了手玩样例环节 f(n) =f (n/2) +1 int m; int f(int x){ return x==1?x:f(x/2)+1; } signed main(){ while(cin>>m) cout<<f(m) 阅读全文
posted @ 2022-10-26 14:51 towboat 阅读(8) 评论(0) 推荐(0) 编辑
cf 1742D
摘要:a[i]<=1000 !!!! #include <iostream> #include <cmath> #include <cstring> using namespace std; int n,b[1003]; int gcd(int x,int y){ return y==0?x:gcd(y, 阅读全文
posted @ 2022-10-26 11:43 towboat 阅读(8) 评论(0) 推荐(0) 编辑
cf1739c
摘要:A,B 打牌(牌的数量为偶数), 计算A赢 B赢 平局的方案数 如果A赢 1.A获得最大的牌, 2.A没有最大的牌,但如果有 n-1 的牌,逼B交n的牌,也可能赢, >>>>> f[n][0]= c(n-1,n/2-1) +f[n-2][1] #include <iostream> using na 阅读全文
posted @ 2022-10-24 11:20 towboat 阅读(13) 评论(0) 推荐(0) 编辑
luogu 1137
摘要:拓扑排序的过程很好描述: 每次访问入度=0 的所有点,删去,而且及时更新入度 在经过拓扑排序的图上求DAG最长路 #include <iostream> #include <queue> using namespace std ; const int N=1e6+3,M=2*N; int n,m; 阅读全文
posted @ 2022-10-20 21:33 towboat 阅读(12) 评论(0) 推荐(0) 编辑
luogu 3143
摘要:题目 在序列中找两个不相交的子序列, 子序列满足 max_number - min_number <=k 动态规划,还需要双指针 正反总共扫两遍(f 和 g) 设 f[i] 为[1,i] 满足要求的序列的最大长度 f[i] = max( f[i-1] , i-j+1) #include <iostr 阅读全文
posted @ 2022-10-17 19:08 towboat 阅读(8) 评论(0) 推荐(0) 编辑
uva11572
摘要:对序列{a} ,找一个最长的连续子序列 ,其中没有相同的数字 双指针 容易想到 O(n^2) 的算法,枚举i ,再枚举一个j 尝试向后延伸 注意到 j到达终点(无法延伸) 时, 朴素算法此时执行 i++,j=i 但其实不必,当 [i,j] 可行时,[i+1,j] 也是可行的,所以此时j继续增大即可, 阅读全文
posted @ 2022-10-17 14:36 towboat 阅读(19) 评论(0) 推荐(0) 编辑
cf1736c1
摘要:对于序列{a} 求其连续子序列{b} 满足 b[i]>=i,有几个? 比如 1 4 6 7 3 , [3],[1,4] [6,7,3]都是合法的 双指针的题 #include <iostream> #include <algorithm> using namespace std; const int 阅读全文
posted @ 2022-10-17 14:27 towboat 阅读(6) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示