摘要: [题目]https://ac.nowcoder.com/acm/contest/7501/A 题意:选出最多数量的数,这组数两两是倍数关系。 解法:1、很容易想到用dp[i]去更新i的倍数,但是会TLE,可以稍作优化,只需更新i的素数倍。比如4,如果只更新素数倍暂时就不会更新到4,而是通过22的方式 阅读全文
posted @ 2020-10-25 20:37 无名菜鸟1 阅读(271) 评论(0) 推荐(1) 编辑
摘要: https://www.acwing.com/problem/content/11/ 01背包最优解计数 #include<bits/stdc++.h> using namespace std ; const int N = 1009 , mod = 1e9 + 7; int dp[N] , cnt 阅读全文
posted @ 2020-10-13 17:35 无名菜鸟1 阅读(98) 评论(0) 推荐(0) 编辑
摘要: 题目 题意:询问任意区间第k小数 #include<bits/stdc++.h> using namespace std ; const int N = 100010 ; int n , m , sz , len , a[N] , b[N] , p; int rt[N<<5] ;//记录第i棵权值线 阅读全文
posted @ 2020-10-12 10:56 无名菜鸟1 阅读(65) 评论(0) 推荐(0) 编辑
摘要: http://keyblog.cn/article-47.html https://blog.csdn.net/wang57389675/article/details/45895473 https://www.cnblogs.com/ECJTUACM-873284962/p/6398385.htm 阅读全文
posted @ 2020-10-08 15:47 无名菜鸟1 阅读(84) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/status.php 题意:给出一棵树,求出所有结点所能到达的最远距离。 解法一:任意一点所能到达的最远距离一定是树的直径的某一端点;由树的直径的性质可得。 #include<bits/stdc++.h> using namespace std ; typ 阅读全文
posted @ 2020-09-06 20:07 无名菜鸟1 阅读(175) 评论(0) 推荐(0) 编辑
摘要: #include <bits/stdc++.h> typedef long long ll ; #define int ll #define ME(x , y) memset(x , y , sizeof(x)) using namespace std ; typedef pair<int,int> 阅读全文
posted @ 2020-08-18 14:31 无名菜鸟1 阅读(600) 评论(0) 推荐(0) 编辑
摘要: 解法:枚举 #include <bits/stdc++.h> typedef long long ll ; #define int ll using namespace std ; int quickpow(int a,int b,int mo){int s;for(s=1;b;b>>= 1,a=a 阅读全文
posted @ 2020-08-10 21:51 无名菜鸟1 阅读(150) 评论(0) 推荐(0) 编辑
摘要: 题意:n个点m条边无向图,求s到t的最少时间,某些地方需要特定的手拿蛋糕,L表示该点必须左手拿,R同理,M没有要求。 解法:dis[i][j] j表示左手或右手到达i点的最少时间。 #include <bits/stdc++.h> typedef long long ll ; #define int 阅读全文
posted @ 2020-08-07 21:04 无名菜鸟1 阅读(179) 评论(0) 推荐(0) 编辑
摘要: 题意:给一张n个节点,m条双向边的图,每条边具有花费,每一天走一条边,每一天也具有花费。 问小明从1号结点到n号结点k天之内能否到达,能到达输出最小花费,否则输出-1。 解法:一开始没有想到建分层图,直接dijkstra贪心走最小花费,但是会出现一个问题,就是 到达一个结点的最小花费,会被其他路径天 阅读全文
posted @ 2020-08-07 20:58 无名菜鸟1 阅读(152) 评论(0) 推荐(0) 编辑
摘要: #include<bits/stdc++.h> typedef long long ll ; #define mod 99999997 #define gcd __gcd #define rep(i , j , n) for(int i = j ; i <= n ; i++) #define red 阅读全文
posted @ 2020-07-26 18:51 无名菜鸟1 阅读(156) 评论(0) 推荐(0) 编辑