今天试图用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>
#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)在抛物线下的话

把式子拆一波

\[x_0^2 + bx_0 + c \geq y_0
\]

\[bx_0 + c \geq -x_0^2 + y_0
\]

然后你会惊讶地发现左边是一个直线方程(废话

这个直线的意义就是 如果这个直线过一个点的话

那么那条抛物线也过它

如果这条直线在那个点上方的话 那么那个点在抛物线外

现在就是一个上凸壳问题

#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)的更多相关文章

  1. [题解] Codeforces Round #549 (Div. 2) B. Nirvana

    Codeforces Round #549 (Div. 2) B. Nirvana [题目描述] B. Nirvana time limit per test1 second memory limit ...

  2. Codeforces Round #549 (Div. 2) 训练实录 (5/6)

    The Doors +0 找出输入的01数列里,0或者1先出完的的下标. Nirvana +3 输入n,求1到n的数字,哪个数逐位相乘的积最大,输出最大积. 思路是按位比较,从低到高,依次把小位换成全 ...

  3. [ 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 ...

  4. Codeforces Round #549 (Div. 2) F 数形结合 + 凸包(新坑)

    https://codeforces.com/contest/1143/problem/F 题意 有n条形如\(y=x^2+bx+c\)的抛物线,问有多少条抛物线上方没有其他抛物线的交点 题解 \(y ...

  5. Codeforces Round #549 (Div. 2) E 倍增处理按排列顺序的上一个位置

    https://codeforces.com/contest/1143/problem/E 题意 p为n的一个排列,给出有m个数字的数组a,q次询问,每次询问a数组区间[l,r]中是否存在子序列为p的 ...

  6. 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为起始位 ...

  7. CodeForces Round #549 Div.2

    A. The Doors 代码: #include <bits/stdc++.h> using namespace std; ; int N; , One = ; int a[maxn], ...

  8. B. Nirvana Codeforces Round #549 (Div. 2) (递归dfs)

    ---恢复内容开始--- Kurt reaches nirvana when he finds the product of all the digits of some positive integ ...

  9. 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 ...

随机推荐

  1. Form 表单提交的几种方式

    简单的总结一下form表单提交的几种方式:1.最简单的方式 就用form的submit提交方式,这种提交方式是不需要回调函数的   这种方式最近到一个form提供action路径后台接受就可以< ...

  2. AppStore IPv6-only审核被拒原因分析及解决方案-a

    Apple关于IPV6规定 日前,苹果公司向开发者发出提醒,公司将会修改应用商店App Store的相关规定,所有IOS应用必须包含对IPv6-only标准的支持.据悉,该规定在6月1日生效,所有提交 ...

  3. .net工具类 获取枚举类型的描述

    一般情况我们会用枚举类型来存储一些状态信息,而这些信息有时候需要在前端展示,所以需要展示中文注释描述. 为了方便获取这些信息,就封装了一个枚举扩展类. /// <summary> /// ...

  4. FreeMarker js 获取后台设置的request、session

    使用Request里的Attribute值最简单的方法就是直接${AttributeName}或者安全一点:${AttributeName!"default Value"} 1.取 ...

  5. 倒计时5S秒自动关闭弹窗

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  6. python的学习笔记01_5文件操作

    一,文件操作基本流程. 计算机系统分为:计算机硬件,操作系统,应用程序三部分. 我们用python或其他语言编写的应用程序若想要把数据永久保存下来,必须要保存于硬盘中,这就涉及到应用程序要操作硬件,众 ...

  7. Dotspatial 空间要素选择

    //通过遍历选择要素,获取选择要素相交的要素 private void toolStripButton43_Click(object sender, EventArgs e) { //查看与选中要素重 ...

  8. 3Delight NSI: A Streamable Render API

    3Delight是应用于高端电影级别渲染的软件渲染器,迄今为止已经参与了无数的电影制作,具体可以参见链接. 如果你对3Delight的印象就依然是RenderMan的替代品,那就显然已经和时代发展脱节 ...

  9. 商米D1S一体机设置搜狗手写输入法图解

    按照下图步骤,一步步设置即可,询问全新的时候需要点击允许. 商米应用市场搜索下载搜狗输入法,并安装 安装完成后,点击桌面搜狗输入法,选择启用搜狗输入法,如图 点击启用后,在虚拟键盘中选择搜狗输入法,并 ...

  10. (五)图数据库数neo4j据备份与恢复

    1.备份方式 neo4j目前有三种备份方式: (1)java在线备份,通过java程序可在neo4j启动状态下备份数据,也可远程备份(社区版本目前不支持) (2)neo4j-admin工具,可在neo ...