12 2023 档案

摘要:有点像完全背包,但也不是因为有数量的限制,是01背包的变式,每个硬币选与不选,最后看看能不能达到x。 #include<bits/stdc++.h> using namespace std; int t[100],w[100],dp[10005]; int main(){ int n,m; cin> 阅读全文
posted @ 2023-12-28 11:45 yufan1102 阅读(5) 评论(0) 推荐(0) 编辑
摘要:A. Distinct Buttons #include<bits/stdc++.h> using namespace std; void solve(){ int n; cin>>n; int a=0,b=0,c=0,d=0; for(int i=1;i<=n;i++){ int x,y; cin 阅读全文
posted @ 2023-12-28 11:35 yufan1102 阅读(28) 评论(0) 推荐(0) 编辑
摘要:可以把题目中的活动看成一个个的区间,那么多的区间可能有相交的,我们要找出不相交且最多的区间 想要区间数量最多化,可以贪心的从区间末开始计算,从区间最小的开始记 #include<bits/stdc++.h> using namespace std; const int N=1e3+10; struc 阅读全文
posted @ 2023-12-28 11:11 yufan1102 阅读(4) 评论(0) 推荐(0) 编辑
摘要:经典的过河卒问题,dp状态很好想,只需注意#不能发生转移即可 #include<bits/stdc++.h> #define int long long using namespace std; const int N=1e3+10; const int mod=1e9+7; char mp[N][ 阅读全文
posted @ 2023-12-24 13:25 yufan1102 阅读(4) 评论(0) 推荐(0) 编辑
摘要:每个点肯定是它上个点转移过来的 #include<bits/stdc++.h> using namespace std; const int N=1e5+10; vector<int>a[N]; int d[N],dp[N]; void solve(){ int n,m; cin>>n>>m; fo 阅读全文
posted @ 2023-12-24 13:23 yufan1102 阅读(12) 评论(0) 推荐(0) 编辑
摘要:这个题目的体积很大,但是价值却很小,最多是1e5,我们可以转变背包体积概念,把价值当作体积,然后体积当作 DP 值。 dp[i] 表示的是达到i价值所需的最小的体积 #include<bits/stdc++.h> #define int long long using namespace std; 阅读全文
posted @ 2023-12-24 13:20 yufan1102 阅读(17) 评论(0) 推荐(0) 编辑
摘要:用dp[i][j] 表示第i天选了j类型的最大值 #include<bits/stdc++.h> using namespace std; const int N=1e5+10; vector<int>a[N]; int dp[N][3]; void solve(){ int n; cin>>n; 阅读全文
posted @ 2023-12-24 13:11 yufan1102 阅读(9) 评论(0) 推荐(0) 编辑
摘要:因为k很小,所以无需优化dp #include<bits/stdc++.h> using namespace std; void solve(){ int n,k; cin>>n>>k; vector<int>a(n+1); vector<int>dp(n+1,1e18); dp[1]=0; for 阅读全文
posted @ 2023-12-24 13:08 yufan1102 阅读(10) 评论(0) 推荐(0) 编辑
摘要:很好想的线性p #include<bits/stdc++.h> using namespace std; void solve(){ int n; cin>>n; vector<int>a(n+1); vector<int>dp(n+1,1e18); dp[1]=0; for(int i=1;i<= 阅读全文
posted @ 2023-12-24 13:06 yufan1102 阅读(5) 评论(0) 推荐(0) 编辑
摘要:A. Rating Increase 字符串处理 #include<bits/stdc++.h> using namespace std; void solve(){ string s; cin>>s; int n=s.size(); s=" "+s; for(int i=1;i<=n-1;i++) 阅读全文
posted @ 2023-12-20 22:04 yufan1102 阅读(23) 评论(0) 推荐(0) 编辑
摘要:A. Problemsolving Log map枚举字母 #include<bits/stdc++.h> using namespace std; void solve(){ int n; string s; cin>>n>>s; int ans=0; s=" "+s; map<char,int> 阅读全文
posted @ 2023-12-20 15:02 yufan1102 阅读(86) 评论(0) 推荐(0) 编辑
摘要:#include<bits/stdc++.h> #define int long long using namespace std; int n,p; int gcd(int a,int b,int &x,int &y){ if(b==0){ x=1; y=0; return a; } int d= 阅读全文
posted @ 2023-12-19 14:34 yufan1102 阅读(4) 评论(0) 推荐(0) 编辑
摘要:C - Error Correction 大意是:给定一个字符串a,以及一组字符串,如果字符串与a满足以下之一即可 我写的有点麻烦。。 #include<bits/stdc++.h> using namespace std; void solve(){ int n; cin>>n; string s 阅读全文
posted @ 2023-12-18 21:58 yufan1102 阅读(7) 评论(0) 推荐(0) 编辑
摘要:模板 #include<bits/stdc++.h> using namespace std; const int N=1e8+10; int p[N]; bitset<N>vis; int n; void ola(){ int cnt=0; for(int i=2;i<=N;i++){ if(!v 阅读全文
posted @ 2023-12-18 21:55 yufan1102 阅读(10) 评论(0) 推荐(0) 编辑
摘要:C - T-shirts 题意是:给定一个string,字符代表每天有不同的事,做不同的事会穿不同的衣服,问你最少需要准备多少T恤。 思路:贪心,能不用T恤就不要T恤 #include<bits/stdc++.h> using namespace std; void solve(){ int n,k 阅读全文
posted @ 2023-12-17 13:43 yufan1102 阅读(24) 评论(0) 推荐(0) 编辑
摘要:C - Sensors 但看数据发现是经典油田问题,直接dfs #include<bits/stdc++.h> using namespace std; int n,m; int dx[8] = {-1, -1, -1, 0, 1, 1, 1, 0}; int dy[8] = {-1, 0, 1, 阅读全文
posted @ 2023-12-17 13:40 yufan1102 阅读(13) 评论(0) 推荐(0) 编辑
摘要:A. Constructive Problems 看了一眼数据,猜测可能是n,m里的最大 #include<bits/stdc++.h> using namespace std; void solve(){ int a,b; cin>>a>>b; int ans=max(a,b); cout<<an 阅读全文
posted @ 2023-12-17 13:38 yufan1102 阅读(79) 评论(0) 推荐(0) 编辑
摘要:思路:需要构造出一种最优解情况 这样就最多能删去2个 #include<bits/stdc++.h> using namespace std; void solve(){ int n; cin>>n; int ans=max(0,n-2); cout<<ans; } int main(){ ios: 阅读全文
posted @ 2023-12-16 13:53 yufan1102 阅读(6) 评论(0) 推荐(0) 编辑
摘要:思路:先用素数筛把20000以内的素数筛出来,然后枚举两个素数 //哥德巴赫猜想(升级) #include<bits/stdc++.h> using namespace std; const int N=20005; bitset<N>vis; vector<int>p; void prime(){ 阅读全文
posted @ 2023-12-16 13:44 yufan1102 阅读(26) 评论(0) 推荐(0) 编辑
摘要:哥德巴赫猜想:任意一个大于2的偶数都可以写成两个质数之和 思路:枚举质数 //哥德巴赫猜想 #include<bits/stdc++.h> using namespace std; bool check(int x){ if(x<=1)return false; for(int i=2;i<=sqr 阅读全文
posted @ 2023-12-16 13:23 yufan1102 阅读(11) 评论(0) 推荐(0) 编辑
摘要:每个数字选与不选的01背包 本题的核心就是每个容量j,最多选t[i]个,然后不断递归 #include<bits/stdc++.h> using namespace std; const int N=105; const int M=1e5+10; int w[N],t[N]; int dp[M]; 阅读全文
posted @ 2023-12-11 22:42 yufan1102 阅读(4) 评论(0) 推荐(0) 编辑
摘要:模板代码 #include<bits/stdc++.h> #define int long long using namespace std; const int N=1e5+10; vector<pair<int,int>>a[N]; int dis[N],vis[N]; int n,m; voi 阅读全文
posted @ 2023-12-11 22:39 yufan1102 阅读(4) 评论(0) 推荐(0) 编辑
摘要:C. Array Game 题意:给定一个n的数组以及k的操作数,每次可以选择下表为i,j(i<j)得到一个abs(a[i]-a[j])的数放在数组末尾,问你k次操作后,数组中最小的数是多少? 思路:首先k>=3 选相同的下表两次,一定结果是0,是最小。 k==1 遍历出下表两两相减的绝对值最小以及 阅读全文
posted @ 2023-12-10 14:23 yufan1102 阅读(240) 评论(0) 推荐(0) 编辑
摘要:A. Rook 打印出象棋车的下一步 using namespace std; void solve(){ string s; cin>>s; char a=s[0]; char b=s[1]; set<string>ans; for(char i='1';i<='8';i++){ string t 阅读全文
posted @ 2023-12-09 10:20 yufan1102 阅读(24) 评论(0) 推荐(0) 编辑
摘要:C - Sum of Numbers Greater Than Me 题意:给定一个长度为n的数组,分别找出比a[i]大的数组里的数的和 思路:用map记录每个数的个数,然后遍历一遍,后面一个项就是数组之和-前面一项-前面的累加 #define int long long using namespa 阅读全文
posted @ 2023-12-09 10:00 yufan1102 阅读(41) 评论(0) 推荐(0) 编辑
摘要:B - Bombs 题意:就是说有一种炸弹,能炸曼哈顿距离的障碍物,要你打印出炸完后的图 模拟 #include<bits/stdc++.h> using namespace std; char mp[50][50]; void solve(){ int n,m; cin>>n>>m; for(in 阅读全文
posted @ 2023-12-03 16:35 yufan1102 阅读(11) 评论(0) 推荐(0) 编辑
摘要:A. Halloumi Boxes 题意:长度为n的数组,你可以逆转最多k长度,问你能不能是数组递增 思路:如果k>=2那么每个数都可以两两交换,如果下表1的地方是1就一定可以,k=1的话单独讨论 using namespace std; void solve(){ int n,k; cin>>n> 阅读全文
posted @ 2023-12-03 16:24 yufan1102 阅读(131) 评论(0) 推荐(0) 编辑
摘要:B - 326-like Numbers 题意:找到一个不小于n的数是326数,定义是 思路:简单的模拟循环即可 #include<bits/stdc++.h> using namespace std; bool check(int x){ vector<int>a; while(x){ a.pus 阅读全文
posted @ 2023-12-03 16:01 yufan1102 阅读(15) 评论(0) 推荐(0) 编辑
摘要:邮递员送信 题目描述 有一个邮递员要送东西,邮局在节点 1。他总共要送 n1 样东西,其目的地分别是节点 2 到节点 n。由于这个城市的交通比较繁忙,因此所有的道路都是单行的,共有 m 条道路。这个邮递员每次只能带一样东西,并且运送每件物品过后必须返回邮局。 阅读全文
posted @ 2023-12-03 14:49 yufan1102 阅读(31) 评论(0) 推荐(0) 编辑
摘要:租用游艇 题目描述 长江游艇俱乐部在长江上设置了 n 个游艇出租站 1,2,,n。游客可在这些游艇出租站租用游艇,并在下游的任何一个游艇出租站归还游艇。游艇出租站 i 到游艇出租站 j 之间的租金为 r(i,j)(\(1\le i\lt j\le 阅读全文
posted @ 2023-12-01 13:59 yufan1102 阅读(29) 评论(0) 推荐(0) 编辑
摘要:简单的dfs从1节点开始往下深搜,然后回溯记录路径 #include<bits/stdc++.h> using namespace std; const int N=1e4+10; vector<int>a[N]; int n,m; vector<int>p; void dfs(int x,int 阅读全文
posted @ 2023-12-01 13:45 yufan1102 阅读(9) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示
🚀
回顶
收起
  1. 1 404 not found REOL
404 not found - REOL
00:00 / 00:00
An audio error has occurred.