Codeforces Round #549 (Div. 1)
今天试图用typora写题解
真开心
你会发现有很多都是参考的。。zblzbl
Codeforces Round #549 (Div. 1)
最近脑子不行啦 需要cf来缓解一下
A. The Beatles
这道题就是枚举啦 有两种步长 试一下就好了
如果你的步长是x
那么要跳的次数就是距离除以步长
\]
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <complex>
#include <ctime>
#include <queue>
using namespace std;
long long n, m, a, b;
long long mxx, mnn;
long long gcd(long long x,long long y){
return y ? gcd(y, x % y) : x;
}
void solve(long long x){
for(int i = 1; i <= n; ++i){
mxx = max(mxx, gcd(x, n * m));
mnn = min(mnn, gcd(x, n * m));
x += m;
}
}
int main(){
scanf("%lld%lld%lld%lld", &n, &m, &a, &b);
if(a < b) swap(a, b);
mxx = 1, mnn = n * m;
solve(a - b); solve(m - a - b);
printf("%lld %lld\n", n * m / mxx, n * m / mnn);
return 0;
}
B. Lynyrd Skynyrd
这道题不用主席树啊喂
向前跳够n - 1个前驱就可以
(前驱就是前面最近的 值在排列里位于前一位的 数
倍增维护一下
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <complex>
#include <ctime>
#include <queue>
using namespace std;
/*
记录每个点的pre 然后维护前面第n-1个pre
*/
const int N = 2e5 + 5;
int n, m, q;
int fro[N], pre[N][25], rec[N], mx[N];
int a[N], b[N], rt[N];
int main(){
scanf("%d%d%d", &n, &m, &q);
for(int i = 1; i <= n; ++i){
scanf("%d", &a[i]);
fro[a[i]] = a[i - 1];
}
fro[a[1]] = a[n];
for(int i = 1; i <= m; ++i){
scanf("%d", &b[i]);
pre[i][0] = rec[fro[b[i]]], rec[b[i]] = i;
for(int j = 1; j <= 20; ++j)
pre[i][j] = pre[pre[i][j - 1]][j - 1];
int pos = i;
for(int j = 20; j >= 0; --j)
if((1 << j) & (n - 1)){
pos = pre[pos][j];
}
mx[i] = max(mx[i - 1], pos);
}
for(int i = 1, x, y; i <= q; ++i){
scanf("%d%d", &x, &y);
printf("%d", mx[y] >= x);
}
return 0;
}
C. U2
这道题真的是完全不会。。学到了学到了。。
如果点(x0, y0)在抛物线下的话
把式子拆一波
\]
\]
然后你会惊讶地发现左边是一个直线方程(废话
这个直线的意义就是 如果这个直线过一个点的话
那么那条抛物线也过它
如果这条直线在那个点上方的话 那么那个点在抛物线外
现在就是一个上凸壳问题
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <complex>
#include <ctime>
#include <queue>
using namespace std;
/*
记录每个点的next 然后维护前面第n-1个pre
*/
const double eps = 1e-9;
const int N = 1e5 + 5;
struct Node{
double x, y;
void init(){y = y - x * x;}
friend Node operator -(Node a, Node b){
return (Node){a.x - b.x, a.y - b.y};
}
}node[N], stk[N];
int n, top;
inline double cross(Node x, Node y){
return x.x * y.y - x.y * y.x;
}
inline bool rule(Node x, Node y){
return fabs(x.x - y.x) < eps ? x.y < y.y : x.x < y.x;
}
int main(){
scanf("%d", &n);
for(int i = 1; i <= n; ++i){
scanf("%lf%lf", &node[i].x, &node[i].y);
node[i].init();
}
sort(node + 1, node + n + 1, rule);
for(int i = 1; i <= n; ++i){
//无论是水平还是述职都要忽略
if(top && fabs(stk[top].x - node[i].x) < eps) --top;
while(top > 1 && cross(node[i] - stk[top - 1], stk[top] - stk[top - 1]) < eps) --top;
stk[++top] = node[i];
}
printf("%d", top - 1);
return 0;
}
Codeforces Round #549 (Div. 1)的更多相关文章
- [题解] Codeforces Round #549 (Div. 2) B. Nirvana
Codeforces Round #549 (Div. 2) B. Nirvana [题目描述] B. Nirvana time limit per test1 second memory limit ...
- Codeforces Round #549 (Div. 2) 训练实录 (5/6)
The Doors +0 找出输入的01数列里,0或者1先出完的的下标. Nirvana +3 输入n,求1到n的数字,哪个数逐位相乘的积最大,输出最大积. 思路是按位比较,从低到高,依次把小位换成全 ...
- [ Codeforces Round #549 (Div. 2)][D. The Beatles][exgcd]
https://codeforces.com/contest/1143/problem/D D. The Beatles time limit per test 1 second memory lim ...
- Codeforces Round #549 (Div. 2) F 数形结合 + 凸包(新坑)
https://codeforces.com/contest/1143/problem/F 题意 有n条形如\(y=x^2+bx+c\)的抛物线,问有多少条抛物线上方没有其他抛物线的交点 题解 \(y ...
- Codeforces Round #549 (Div. 2) E 倍增处理按排列顺序的上一个位置
https://codeforces.com/contest/1143/problem/E 题意 p为n的一个排列,给出有m个数字的数组a,q次询问,每次询问a数组区间[l,r]中是否存在子序列为p的 ...
- Codeforces Round #549 (Div. 2) D 数学
https://codeforces.com/contest/1143/problem/D 题意 有nk个城市,第1,k+1,2k+1,...,(n-1)k+1城市有餐厅,你每次能走l距离,a为起始位 ...
- CodeForces Round #549 Div.2
A. The Doors 代码: #include <bits/stdc++.h> using namespace std; ; int N; , One = ; int a[maxn], ...
- B. Nirvana Codeforces Round #549 (Div. 2) (递归dfs)
---恢复内容开始--- Kurt reaches nirvana when he finds the product of all the digits of some positive integ ...
- C. Queen Codeforces Round #549 (Div. 2) (搜索)
---恢复内容开始--- You are given a rooted tree with vertices numerated from 11 to nn . A tree is a connect ...
随机推荐
- 多态以及 LeetCode 每日一题
1 多态 1.1 多态性 Java 引用变量有两个类型:一个是编译时类型,一个是运行时类型.前者是代码中声明这个变量时的类型,后者是由实际对象的类型决定的.当编译类型和运行类型不一样时,产生多态. c ...
- PPT在HTML网页上播放方法
项目中遇到一个需求:要求PPT在HTML网页上播放,而且要像电脑一样播放PPT,大家能想到的是什么方法? 印象中我好像有在网上见到过PPT模板网站上的PPT可以播放,赶紧百度搜了下发现都是用第三方软件 ...
- CSS的使用方法
参考资料:http://css.cuishifeng.cn/ 一.CSS的四种引入方式 1.行内式 行内式是在标记的style属性中设定CSS样式.这种方式没有体现出CSS的优势,不推荐使用(与链接式 ...
- php中读取中文文件夹及文件报错
php读取时出现中文乱码 一般php输出中出现中文乱码我们可用 header ('content:text/html;charset="utf-8"'); php中读取中文文件夹及 ...
- Android Material Design控件使用(一)——ConstraintLayout 约束布局
参考文章: 约束布局ConstraintLayout看这一篇就够了 ConstraintLayout - 属性篇 介绍 Android ConstraintLayout是谷歌推出替代PrecentLa ...
- 【抱怨文】vscode对多项目支持不够友好
vscode是一个简单的开发工具,启动快,速度快.但是当前1.26版本对多项目支持好像有点问题.命令行有个dotnet sln,但是只能添加新项目,却没有创建解决方案的命令.如果强行添加他会提示没有解 ...
- 数据库原理剖析 - 序列1 - B+树
本文节选自<软件架构设计:大型网站技术架构与业务架构融合之道>第6.3章节. 作者微信公众号: 架构之道与术.进入后,可以加入书友群,与作者和其他读者进行深入讨论.也可以在京东.天猫上购买 ...
- .Net Core 在Linux服务器下部署程序--(3). 部署.net Core程序
确认第二步中的软件已安装完成 lrzsz文件上传下载软件 zip与unzip压缩包软件 net core 相关软件 确认上述软件安装完成之后,开始部署程序 创建部署文件夹 我的习惯是在usr文件夹下新 ...
- android测试用例编写
说明:android中写测试用例也是用junit,测试用例代码风格是junit3的风格.java中测试用例中使用junit3需要继承TestCase(junit4则不需要,直接用annotation即 ...
- Docker: Jenkins里的pipeline编写基本技巧
Jenkins里,先新建一个pipeline项目 Pipeline Syntax 在Sample Step里选择需要的插件,如果不存在,就去系统管理,插件管理里,进行安装. 如果源码管理工具用的是gi ...