代码源div2-每日一题
代码源div2-每日一题
why151
这个作者很懒,什么都没留下…
展开
-
01序列(前缀和)
题目描述:主要思路:开始想着用双指针做吧,写着写着发现不会写了,后来看了dalao的题解之后,发现,这是一道前缀和且需要特判k=0的题目。#include<iostream>#include<algorithm>#include<cstring>#include<unordered_map>using namespace std;typedef long long ll;const int N=1e6+10;ll sum[N];unor原创 2022-04-18 14:47:38 · 516 阅读 · 3 评论 -
跳跳(gcd+去重)
题目描述:主要思路:开始想的是一个n3的算法,后来看了题解发现只要每次都把他处理成最小的步长然后放进set里就不用再手动比较去重了#include<iostream>#include<algorithm>#include<cstring>#include<set>#include<cmath>using namespace std;typedef pair<int,int> pa;set<pa> ans原创 2022-04-14 15:08:46 · 219 阅读 · 0 评论 -
加一(预处理)
题目描述:主要思路:#include<iostream>#include<algorithm>#include<cstring>using namespace std;const int N=2e5+10;typedef long long ll;const int mod=1e9+7;ll f[20][N];ll ff[20];void init(){ for(int i=0;i<10;i++) { ff[原创 2022-04-13 14:08:00 · 92 阅读 · 0 评论 -
最大和上升子序列(dp)
题目描述:主要思路:#include<iostream>#include<algorithm>#include<cstring>using namespace std;int a[1010];int f[1010]; // 表示取第i个所得的和int main(){ int n; cin>>n; int ans=0; for(int i=1;i<=n;i++) cin>>a[i];原创 2022-04-12 10:22:55 · 94 阅读 · 0 评论 -
任务分配(dp)
题目描述:主要思路:#include<iostream>#include<algorithm>#include<cstring>using namespace std;int f[1010];struct node{ int s,e,w;}a[1010];bool cmp(node a,node b){ if(a.s!=b.s) return a.s<b.s; return a.e<b.e;}原创 2022-04-11 20:39:57 · 183 阅读 · 0 评论 -
饿饿 饭饭(二分答案+双端队列)
题目描述:主要思路:先二分答案 找出前几轮整 最后再跑剩下的几个 注意一下特殊情况(打不完k次就没人吃饭了,刚好)#include<iostream>#include<algorithm>#include<cstring>#include<deque>using namespace std;typedef long long ll;const int N=1e5+10;ll a[N];ll n,k;deque<ll>原创 2022-04-06 15:05:00 · 222 阅读 · 0 评论 -
订单编号(区间覆盖)
问题描述:主要思路:因为数据范围太大了,没有办法直接暴力实现。所以采用区间覆盖的方法,将右左边界加入set中,然后依次选取即可。#include<iostream>#include<algorithm>#include<cstring>#include<set>using namespace std;typedef long long ll;typedef pair<ll,ll> pa;set<pa> a;in原创 2022-04-04 09:16:46 · 217 阅读 · 0 评论 -
走路(简单布尔dp)
题目描述:主要思路:看这个题可以想到这是dp,奈何本人dp基础十分薄弱…#include<iostream>#include<algorithm>#include<cstring>using namespace std;typedef long long ll;const int N=1e5+10;ll a[110],b[110];bool f[110][N];int main(){ int n,m; cin>>n&g原创 2022-03-24 21:29:10 · 387 阅读 · 0 评论 -
走楼梯2(简单dp)
题目描述:楼梯有 n 阶,上楼可以一步上一阶,也可以一步上二阶。但你不能连续三步都走两阶,计算走到第n阶共有多少种不同的走法。对于100%的数据,保证n≤50。主要思路:之前做过基础版的爬楼梯,就是斐波那契数列的问题,但是这次加上了一个限制。#include<iostream>#include<algorithm>#include<cstring>using namespace std;typedef long long ll;ll f[60][10原创 2022-03-24 18:57:21 · 579 阅读 · 0 评论