- 博客(8)
- 收藏
- 关注
原创 2020牛客多校第三场 H 笛卡尔树
大致题意:给定一个长度为n的字符串S,字符串满足“01234567890123…”。给出长度为n的数列p和数列d,执行n次操作,每次操作将S[p[i]]位置的数字替换成d[i],每次操作都会得到一个新的字符串,求这(n+1)个字符串的先后顺序。 思路:首先,很容易知道,如果第i次操作把字符串的第一个位置也就是S[0]替换成更小的数字,那么在第i次操作后得到的所有字符串都比第i次操作前得到的字符串大。 比如第i次操作前,得到的字符串全都是"4…" 将4替换成2后,得到的字符串都是“2…” 所以,如果将第一个位
2020-07-22 11:32:10
272
原创 2020牛客多校第四场 B
2020牛客多校第四场 B 解法: 如果要最优,必须要使gcd的次数最多。 已知x=p1k1p2k2… 我们可以让y=gcd(i,x)=p1k1-1p2k2… 以此类推,最多可以执行(k1+k2+…kn)次。 #include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 1e6; bool vis[N+10]; int p[N+10],a[N+10]; void init(int n){
2020-07-20 20:10:46
274
原创 Codeforces Round #631 (Div. 2) D
Codeforces Round #631 (Div. 2) D dp 不错 #include<bits/stdc++.h> using namespace std; typedef long long ll; const int N=1e5+10; int dig[40],m; ll dp[40]; ll pow2[40]; int main() { int t; c...
2020-04-20 14:56:04
204
原创 Codeforces Round #627 (Div. 3) F
Codeforces Round #627 (Div. 3) F 写完A,发现题目太难, 只能跳过BCDE,把F过了被迫下线QAQ 简单的树形dp #include<bits/stdc++.h> using namespace std; const int N=2e5+10; int head[N],cnt; int val[N]; struct edge{ int next,...
2020-04-20 14:53:14
200
原创 2019 ICPC Universidad Nacional de Colombia Programming Contest 题解
2019 ICPC Universidad Nacional de Colombia Programming Contest 题解 A:貌似是计算几何 #include<bits/stdc++.h> using namespace std; struct vec{ int x,y; vec(int _x,int _y):x(_x),y(_y){ int d=__gcd(x,y)...
2020-04-20 14:43:44
951
原创 牛客练习赛61题解
牛客练习赛61 题解 A:正义感爆棚去打怪 #include<bits/stdc++.h> using namespace std; int main(){ int t; scanf("%d",&t); while(t--){ int h,a,H,A; scanf("%d %d %d %d",&h,&a,...
2020-04-20 14:19:44
361
原创 牛客小白月赛24 题解
牛客小白月赛24 题解 最后还剩一道计算几何,其实可以AK,但没必要/// B:签到 #include <bits/stdc++.h> using namespace std; const int N=2e5+10; int a[N]; int main() { int t;scanf("%d",&t); while(t--){ int n,...
2020-04-20 14:13:09
382
原创 2019 JUST Programming Contest 题解
2019 JUST Programming Contest 题解 #还行 A:还行 #include <bits/stdc++.h> using namespace std; typedef long long ll; const int N=1e5+10; const int M=2e5+10; int head[N],cnt=1,tot,dfn[N],low[N],num,n,...
2020-04-20 13:53:26
314
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅