今天试图用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. EF 外键不显示、如何让外键显示!增、删、改 操作时,外键不显示,只显示导航属性!

    一.问题描述:EF 外键不显示.如何让外键显示!增.删.改 操作时,外键不显示,只显示导航属性! EF 添加.增加.插入数据时,外键不显示! 二.解决方案:在根据数据库生成模型的时候,选中“在模型中” ...

  2. .net面向对象设计原则

    稳定的框架来源于好的设计,好的设计才能出好的作品,掌握面向对象基本原则才会使我们的设计灵活.合理.不僵化,今天就来谈一谈我们.net 面向对象设计的基本原则. 对于一个没有任何设计经验的开发者来说,如 ...

  3. 我的Spring Boot学习记录(一):自动配置的大致调用过程

    1. 背景 Spring Boot通过包管理工具引入starter包就可以轻松使用,省去了配置的繁琐工作,这里简要的通过个人的理解说下Spring Boot启动过程中如何去自动加载配置. 本文中使用的 ...

  4. js调用百度地图接口绘制任意多边形并获取每个点的经纬度等

    来自:https://blog.csdn.net/u013239236/article/details/52213977 侵删 <!DOCTYPE html> <html> & ...

  5. Dynamics 365中显示格式为URL的字段极少部分URL值录入了不显示怎么回事?

    微软动态CRM专家罗勇 ,回复318或者20190315可方便获取本文,同时可以在第一间得到我发布的最新博文信息,follow me!我的网站是 www.luoyong.me . 对于如下类型的字段, ...

  6. Odoo 菜单美化的扩展模块

    详见: http://www.oejia.net/blog/2018/07/07/oejia_menu_about.html Odoo 菜单美化主题,odoo默认的菜单算是简洁好用的,如果您觉得还少了 ...

  7. weblogic doc

    BEA WebLogic Server 9.2 Documentation https://docs.oracle.com/cd/E13222_01/wls/docs92/index.html 8.1 ...

  8. 【RL-TCPnet网络教程】第2章 嵌入式网络协议栈基础知识

    第2章        嵌入式网络协议栈基础知识 本章教程为大家介绍嵌入式网络协议栈基础知识,本章先让大家有一个全面的认识,后面章节中会为大家逐一讲解用到的协议. 基础知识整理自百度百科,wiki百科等 ...

  9. 使用git提交代码到github,每次都要输入用户名和密码的解决方法

    自从使用git提交代码到github后,发现自己使用git的功力增长了不少,但也遇到不少问题.比如,使用git提交代码到github的时候,经常要求输入用户名和密码,类似这种: 网上有这么一种解决方法 ...

  10. Azure存储账户的日志分析方法

    1.首先确认日志功能是否开启(日志文件根据存储账户的类型,按使用量收费 . 2.在存储账户-Usage(classic)-Metrics中查看突出流量的时间: 3.在Explorer中下载对应时间点的 ...