今天试图用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. docker run 之后执行多条命令

    执行 ls docker run microsoft/dotnet ls && cd /root 执行 多条使用sh -c命令 在run后面加了一个sh -c命令,后面直接加多条语句即 ...

  2. HTML5支持服务器发送事件(Server-Sent Events)-单向消息传递数据推送(C#示例)

    传统的WEB应用程序通信时的简单时序图: 现在Web App中,大都有Ajax,是这样子: HTML5有一个Server-Sent Events(SSE)功能,允许服务端推送数据到客户端.(通常叫数据 ...

  3. IT企业级应⽤开发模式演化

    前端研发流程 传统To B类系统的研发模式 探索 & 思考设计模式库(DPL)设计语⾔设计语⾔详解基于MVVM模式的Web框架 & UI库优化后的开发模式实现价值实践 赋能 赋能授权( ...

  4. SAP HUM 拆包之后的HU号码依旧存在

    比如HU 194811210666,已经被执行了Unpack操作. HUMO看这个HU号码, 执行, 可以发现,这个HU是空的,里面什么都没有. 双击HU号码,进入HU显示界面, 系统状态竟然是PHE ...

  5. Dynamics 365-N:N Relationship的记录处理

    在Dynamics CRM中,两个Entity之间是可以有N:N Relationship的,但是CRM实现N:N,是通过系统自创建一个中间表来实现的.这个中间表,如果环境是OnPremise,可以根 ...

  6. Android为TV端助力 电影栏目移动到底部或者顶部时抖动动画

    1 移动到底部上下抖动ObjectAnimator animatorX = ObjectAnimator.ofFloat(holder.itemView,"translationX" ...

  7. Android Studio项目用Git上传至码云(OSChina)

    工具: Git安装(官网下载,默认安装即可). 步骤一: 新建一个Android Studio项目: 步骤二: 申请OSChina账号.登陆并创建新项目 1. 2. 3.点击复制,下面在Android ...

  8. 云服务器内,nginx安装部署,Xshell,Xftp安装

    nginx部署 三丰云云服务器,安装nginx nginx部署 在宝塔面板,添加Nginx安装,一般进来会默认推荐安装几款软件,mysql等,暂时可以后面再装,先把nginx装上去,去感受将前端页面放 ...

  9. IDEA启动tomcat乱码

    1.找到IDEA安装目录 2.找到2个文件 3.编辑,在最后一行加入 -Dfile.encoding=UTF-8 4.修改IDEA里tomcat内得编码 5.修改IDEA中tomcat中,startu ...

  10. rabbitmq之简述HAProxy配置集群过程

    简介 HAProxy是一款提供高可用性.负载均衡以及基于TCP和HTTP应用的代理软件,HAProxy是完全免费的.借助HAProxy可以快速并且可靠的提供基于TCP和HTTP应用的代理解决方案.HA ...