加载中...

上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 19 下一页
摘要: ##越狱 https://www.acwing.com/problem/content/1292/ n个房间m个宗教 求2个相同相邻宗教的情况 : 正难则反 ! m^n-m*(m-1)^(n-1) //所有情况-每个房间信奉不同宗教的情况(第一个房间是m 第二情况必须不同所以是m-1) cout < 阅读全文
posted @ 2022-08-06 23:50 liang302 阅读(40) 评论(0) 推荐(0)
摘要: N=(p1^c1)(p2^c2)...(pk^ck) N^2=(p1^(c1**2)) * (p2^ (c22) )...(pk^ (ck*2) ) ##约数个数 f[N]=(c1+1)(c2+1)...(cn+1) ##拍打牛头https://www.acwing.com/problem/cont 阅读全文
posted @ 2022-08-06 23:47 liang302 阅读(61) 评论(0) 推荐(0)
摘要: ##相邻质数距离 https://www.acwing.com/problem/content/198/ #include <cstring> #include <iostream> #include <algorithm> using namespace std; typedef long lon 阅读全文
posted @ 2022-08-06 18:06 liang302 阅读(45) 评论(0) 推荐(0)
摘要: #三种祖先关系 a是b祖先 b是a祖先 a和b不是祖先关系 #树上多个点的LCA,就是DFS序最小的和DFS序最大的这两个点的LCA 必备:知道根节点 必须存下来 有可能跳过根节点 int depth[N],f[][N];//N为(log节点数)+1 int q[N]; 从根节点开始预处理; 需要设 阅读全文
posted @ 2022-07-25 14:49 liang302 阅读(72) 评论(0) 推荐(0)
摘要: ##https://ac.nowcoder.com/acm/contest/33187/K 给出子串和母串长度 求母串的可能性 #include <iostream> #include <cstring> using namespace std; using i64 = long long; con 阅读全文
posted @ 2022-07-23 18:40 liang302 阅读(35) 评论(0) 推荐(0)
摘要: ##大盗阿福https://www.acwing.com/problem/content/1051/ f[i][0]表示不偷第i家的最大费用 两个状态 偷这家+不偷这家+ #include <iostream> #include <cstring> #include <algorithm> usin 阅读全文
posted @ 2022-07-23 17:32 liang302 阅读(20) 评论(0) 推荐(0)
摘要: ##兴奋值 https://ac.nowcoder.com/acm/contest/37160/H #include <algorithm> #include <iostream> #include <cstring> #include <cstdio> #include <cmath> using 阅读全文
posted @ 2022-07-21 18:32 liang302 阅读(48) 评论(0) 推荐(0)
摘要: ##樱果运算 https://ac.nowcoder.com/acm/contest/37160/J 因为每次给的要啦的货是变量 体积1是几辆车 体积2是多少钱 当给出多个价钱和 只要输出对应f[][]载货量 就可以 #include <iostream> using namespace std; 阅读全文
posted @ 2022-07-21 18:07 liang302 阅读(38) 评论(0) 推荐(0)
摘要: #注意NIM里面取走的石子 不一定是减去 根据题意 如果是整除 那可能是除去 奇数一定存在一个偶数后继 偶数的所有后继一定是奇数 ##可以拿走从任意一个堆 取走任意的石子,取走最后一个石子胜利 NIM博弈 无法操作的人输 对于先手:永远将奇数台阶保持不变 我永远看到奇数层不一致的 对手看到永远是 一 阅读全文
posted @ 2022-07-20 01:43 liang302 阅读(70) 评论(0) 推荐(0)
摘要: int getmin(int l,int r){ int res=l; for (int i = l; i <= r; i ++ ){ if(w[res]>w[i]){ res=i; } } return res; } void dfs(int l,int r,int d){ if(l>r){//树 阅读全文
posted @ 2022-07-13 22:07 liang302 阅读(28) 评论(0) 推荐(0)
上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 19 下一页