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 ...
随机推荐
- EasyUI List<T>转tree数据格式
using System; using System.Collections; using System.Collections.Generic; using System.Linq; using S ...
- 【转】Redis一般会遇到的问题以及解析
单线程的 Redis 为什么这么快 这个问题是对 Redis 内部机制的一个考察.根据我的面试经验,很多人都不知道Redis 是单线程工作模型.所以,这个问题还是应该要复习一下的. 回答主要是以下三点 ...
- hive基本操作与应用
通过hadoop上的hive完成WordCount 启动hadoop Hdfs上创建文件夹 上传文件至hdfs 启动Hive 创建原始文档表 导入文件内容到表docs并查看 用HQL进行词频统计,结果 ...
- Vue 无限滚动加载指令
也不存在什么加载咯, 就是一个判断滚动条是否到达浏览器底部了. 如果到了就触发事件,米到就不处理. 计算公式提简单的 底部等于(0) = 滚动条高度 - 滚动条顶部距离 - 可视高度. 反正结 ...
- Swiper4.x使用方法
1.首先加载插件,需要用到的文件有swiper.min.js和swiper.min.css文件.可下载Swiper文件或使用CDN. <!DOCTYPE html> <html> ...
- Android破解学习之路(十四)——【Unity3D】王牌大作战破解
一.前言 今天带来的是王牌大作战的破解教程,游戏下载的话,我是直接去TapTap官网下载的 支付宝内购破解用老套了,今天学点破解的新花样吧!! 二.支付宝内购破解 支付宝的内购破解已经很熟悉了, 直接 ...
- 前端开发之基础知识-HTML(二)
1.6 html链接 html链接 <a>标签可以在网页上定义一个链接地址,通过src属性定义跳转的地址,通过title属性定义鼠标悬停时弹出的提示文字框. <a href=&quo ...
- Java基础系列--05_面向对象
1.概述: (1)面向过程:将问题一步一步的解决的过程(详细步骤),在C语言中所有的代码都是基于过程化的代码. (2)面向对象:面向对象是基于面向过程的编程思想,所有的事情都交由创建出来的对象去指挥. ...
- 为什么要花钱学 Python,自学不好吗?
买了这么多课程,有哪一门是你从头到尾听完,并且能将知识点学以致用的?如果你想成为一名相对优秀的程序员,建议你读完这篇文章,如果愿意可以分享给你的朋友. 2018过去的一年,对大多数互联网人来说,201 ...
- EntityFramework Core是否可以映射私有属性呢?了解一下。
前言 最近几天身体有点抱恙,说话都需要勇气,痛哭.今天简短的写一点探索性的内容,仅供了解,感谢您的阅读. EF Core映射私有属性 在EF 6.x系列中写过一篇文章可以映射私有属性,说明EF的灵活性 ...