Codeforces Round #549 (Div. 2)A. The Doors】的更多相关文章

A. The Doors time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Three years have passes and nothing changed. It is still raining in London, and Mr. Black has to close all the doors in his home…
Codeforces Round #549 (Div. 2) B. Nirvana [题目描述] B. Nirvana time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Kurt reaches nirvana when he finds the product of all the digits of some positive int…
今天试图用typora写题解 真开心 参考 你会发现有很多都是参考的..zblzbl Codeforces Round #549 (Div. 1) 最近脑子不行啦 需要cf来缓解一下 A. The Beatles 这道题就是枚举啦 有两种步长 试一下就好了 如果你的步长是x 那么要跳的次数就是距离除以步长 \[ \frac{n * k * x}{gcd(n * k, x)} \div x = \frac{n * k}{gcd(n * k, x)} \] #include <cmath> #in…
The Doors +0 找出输入的01数列里,0或者1先出完的的下标. Nirvana +3 输入n,求1到n的数字,哪个数逐位相乘的积最大,输出最大积. 思路是按位比较,从低到高,依次把小位换成全9,判断一下.细节上容易出错,比如边界和减一的情况.要多加小心. Queen +0 给一棵树,删除树中一些点,这些点的\(C_i\)权值是1,且直接的孩子也也是1.从小到大依次输出删除的编号. 中间我以为是所有子孙的权值都要是1,幸好发现了. The Beatles /+0 给一个\(n \cdot…
A. The Doors 代码: #include <bits/stdc++.h> using namespace std; ; int N; , One = ; int a[maxn], b[maxn], suma[maxn], sumb[maxn]; int num1, num2, ans; int main() { scanf("%d", &N); ; i < N; i ++) { scanf("%d", &a[i]); )…
https://codeforces.com/contest/1143/problem/D D. The Beatles time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Recently a Golden Circle of Beetlovers was found in Byteland. It is a circle rou…
传送门 A.The Doors 看懂题目就会写的题 给一个 $01$ 序列,找到最早的位置使得 $0$ 或 $1$ 已经全部出现 #include<iostream> #include<cstdio> #include<algorithm> #include<cstring> #include<cmath> using namespace std; typedef long long ll; inline int read() { ,f=; ch…
https://codeforces.com/contest/1143/problem/F 题意 有n条形如\(y=x^2+bx+c\)的抛物线,问有多少条抛物线上方没有其他抛物线的交点 题解 \(y=x^2+bx+c=>y+x^2=bx+c\),转换为点\((x,y+x^2)\)在bx+c的直线上 两个点确定一条抛物线,同时也确定了一条直线 需要选择最上面那些点相邻确定的抛物线,所以维护一个上凸包即可 维护上凸包,当前点在前进方向左边需要向后退,cross(a,b)>=0 代码 #inclu…
https://codeforces.com/contest/1143/problem/E 题意 p为n的一个排列,给出有m个数字的数组a,q次询问,每次询问a数组区间[l,r]中是否存在子序列为p的循环排列 题解 预处理出值x在排列中的上一个值_p[x] 从左向右扫一遍a数组,维护值x最后出现的地方\(pre[x]\),和每个位置i在排列顺序下前j个数在数组中的位置\(par[i][j]\)(倍增),然后能处理出每个位置i在排列顺序下前n-1个数的位置\(v[i]\) 线段树维护v数组的区间最…
https://codeforces.com/contest/1143/problem/D 题意 有nk个城市,第1,k+1,2k+1,...,(n-1)k+1城市有餐厅,你每次能走l距离,a为起始位置离最近餐厅的距离,b为走了一次后离最近餐厅的距离,给出n,k,a,b,求你回到起点最少和最多停留次数 题解 \(yl=xnk,有y=xnk/l,即y=lcm(xnk,l)/l\) 枚举a(两种情况),b(两种情况),维护最大,最小值 代码 #include<bits/stdc++.h> #def…