摘要: https://minamimelon.github.io/ 阅读全文
posted @ 2021-09-04 15:29 chwhc 阅读(56) 评论(0) 推荐(0) 编辑
摘要: This blog is a derivative of 数位dp总结 之 从入门到模板 by wust_wenhao (csdn) #51 D. Beautiful numbers (数位dp+离散化)under CC 4.0 BY-SA, example codes are modified, 阅读全文
posted @ 2021-04-14 00:30 chwhc 阅读(85) 评论(0) 推荐(0) 编辑
摘要: 高斯消元 模板 luogu P3389 #include<bits/stdc++.h> using namespace std; const double eps=1e-6; const int N=100+5; double a[N][N]; int n; int gauss(){ int c,r 阅读全文
posted @ 2021-03-26 11:30 chwhc 阅读(91) 评论(0) 推荐(0) 编辑
摘要: BSGS BSGS(baby-step giant-step),即大步小步算法。常用于求解离散对数问题。形式化地说,该算法可以在 \(O(\sqrt{p})\) 的时间内求解 \[ a^x \equiv b \pmod p \] 其中 \(a\perp p\)。方程的解 \(x\) 满足 \(0 \ 阅读全文
posted @ 2021-03-12 14:55 chwhc 阅读(67) 评论(0) 推荐(0) 编辑
摘要: 对于一个 \(n\) 个顶点的凸多边形,它的任何三条对角线都不会交于一点。请求出图形中对角线交点的个数。 练python刷简单题刷到了这个,挺有趣的一道题目。 1 对于一个 \(n\) 边形,选任意一个点A可以引出$n-3$条对角线。相邻的点B再引出$n-3$条线,分别与前者有$1,2 ... n- 阅读全文
posted @ 2020-08-10 20:47 chwhc 阅读(337) 评论(1) 推荐(0) 编辑
摘要: 第一次用结构体代替dp数组,这个题没有标明树的深度,用数组存二叉树会爆内存。 /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * 阅读全文
posted @ 2020-08-05 12:47 chwhc 阅读(107) 评论(0) 推荐(0) 编辑
摘要: 好久之前写的,登陆博客看了下好久没更新了,就随手发出来吧。 用这份代码,QT套了个界面设置速度和地图大小。QT的代码就不发了hhh,毕竟源代码分好几个文件 懒 。 用了Windows.h 所以只能在Windows下运行。 #include<Windows.h> #include<iostream> 阅读全文
posted @ 2020-07-31 19:31 chwhc 阅读(128) 评论(0) 推荐(0) 编辑
摘要: ```cpp #include #define LOCAL //无参宏 //条件编译 #ifdef LOCAL int a=1; #else int a=2; #endif #ifndef LOCAL int b=1; #else int b=2; #endif #define PI 3.1415926535 //有参宏 #define max_wrong(a,b) a>b?a:b #define 阅读全文
posted @ 2020-02-27 18:26 chwhc 阅读(188) 评论(1) 推荐(0) 编辑
摘要: 退役后无聊自制了一个游戏... 本想打个2048,限于能力,就照着半成品改成了这个。 Cmd输出太慢有点晃眼。 cpp include include include include include include include using namespace std; const int MAX 阅读全文
posted @ 2018-01-10 13:29 chwhc 阅读(195) 评论(1) 推荐(0) 编辑
摘要: ██████████████████████████████ 【数据删除】 所有读者已经经历A级记忆消除。 阅读全文
posted @ 2017-12-17 12:56 chwhc 阅读(241) 评论(2) 推荐(0) 编辑
摘要: 已经写过本题用二分图的做法, "见这儿" 。 本题的图是一棵树,求最小点覆盖也可以用树形DP的做法。 定义状态f[0/1][u]表示以u为根的子树,u选取/不选最少需要选取多少点来覆盖。 显然 f[0][u] = Sigma{f[1][v]},f[1][u] = Sigma{min(f[0][v], 阅读全文
posted @ 2017-11-02 18:50 chwhc 阅读(106) 评论(0) 推荐(0) 编辑
摘要: The cows, who always have an inferiority complex about their intelligence, have a new guessing game to sharpen their brains.A designated 'Hay Cow' hid 阅读全文
posted @ 2017-11-01 19:47 chwhc 阅读(113) 评论(0) 推荐(0) 编辑
摘要: 一道数论好题,知识点涉及扩展欧几里得,快速幂,逆元,二项式定理,模运算,组合数等。 (~~别问为啥打了快速幂不用费马小求逆元...我就练习下扩欧~~) (~~数据就应该再加大些卡掉n^2递推求组合数的~~) 阅读全文
posted @ 2017-10-31 07:31 chwhc 阅读(135) 评论(0) 推荐(0) 编辑
摘要: "原题链接" 此题求二分图的最小点覆盖,数值上等于该二分图的最大匹配。得知此结论可以将图染色,建有向图,然后跑匈牙利/网络流,如下。然而... 还有DP解法,待填。 11.02UPD "树形DP解法" 阅读全文
posted @ 2017-10-27 09:32 chwhc 阅读(194) 评论(0) 推荐(0) 编辑
摘要: NOIP2012 疫情控制 题解(LuoguP1084) 不难发现,如果一个点向上移动一定能控制更多的点,所以可以二分时间,判断是否可行。 但根节点不能不能控制,存在以当前时间可以走到根节点的点,可使向下走到深度为2的节点控制 其他点,此时又可以进行另一个贪心,优先选择走到根节点还能再走的时间小的去 阅读全文
posted @ 2017-10-24 19:33 chwhc 阅读(154) 评论(0) 推荐(0) 编辑
摘要: Sorting a Three Valued Sequence IOI'96 Day 2 Sorting is one of the most frequently performed computational tasks. Consider the special sorting problem 阅读全文
posted @ 2017-10-20 20:33 chwhc 阅读(178) 评论(0) 推荐(0) 编辑
摘要: Arithmetic Progressions USACO1.4 An arithmetic progression is a sequence of the form a, a+b, a+2b, ..., a+nb where n=0,1,2,3,... . For this problem, a 阅读全文
posted @ 2017-10-19 21:55 chwhc 阅读(213) 评论(0) 推荐(0) 编辑
摘要: "原题链接" 经典贪心,转化为问题为,对于所有的区间,求最小的点数能使每个区间都至少有一个点。 cpp include include include include include include using namespace std; const int MAXN=100000+5; cons 阅读全文
posted @ 2017-10-17 17:10 chwhc 阅读(132) 评论(0) 推荐(0) 编辑
摘要: 拦截导弹 题意:求最长不上升子序列长度;求一个序列最少分成几个非增子序。 第一问易求,已知序列a,令f[i]为a前i个元素的最长非增子序的长度,则有 f[i]=max{f[i],f[j]+1} (1=h[i]). LIS另有nlogn做法,设g[i]为长度为i的最长不上升结尾最小是什么,二分查找更新 阅读全文
posted @ 2017-10-17 13:23 chwhc 阅读(150) 评论(2) 推荐(0) 编辑
摘要: 一开始是不会的,不知道如何处理相等的情况,瞎贪心一直WA。 于是就递归处理是让相等的平局还是输掉,如下,拿到了50分。 cpp int solve(int a,int b,int i,int l,int r) { int ans=0; for(;ib[l]) ans+=2,++l; else if( 阅读全文
posted @ 2017-10-17 07:56 chwhc 阅读(97) 评论(0) 推荐(0) 编辑
摘要: "题目链接" 考虑正序去除点去掉其所有连边十分复杂,可以倒序离线处理,每次新建一个点,连接其连边,用并查集统计联通块的个数。 附代码 cpp include include include using namespace std; const int MAXN=400000+5; int ans[M 阅读全文
posted @ 2017-10-15 13:18 chwhc 阅读(129) 评论(0) 推荐(0) 编辑