A.枚举一个区间,判断是否有数符合。

#include<bits/stdc++.h>
using namespace std; long long l,r,x,y,k; int main()
{
ios::sync_with_stdio();
cin >> l >> r >> x >> y >> k;
for(int i = x;i <= y;i++)
{
if(l <= i*k && i*k <= r)
{
cout << "YES" << endl;
return ;
}
}
cout << "NO" << endl;
return ;
}

B.判断两个边界。

#include<bits/stdc++.h>
using namespace std; int r,d,n; int main()
{
ios::sync_with_stdio();
cin >> r >> d >> n;
int ans = ;
for(int i = ;i <= n;i++)
{
double x,y,rr;
cin >> x >> y >> rr;
double dis = sqrt(x*x+y*y);
if(dis-rr > r-d-1e- && dis+rr < r+1e-) ans++;
}
cout << ans << endl;
return ;
}

C.暴力判断每种gcd,set去重后实际的数量很少。

#include<bits/stdc++.h>
using namespace std; int n,a[],ans[] = {};
vector<int> v[];
set<int> s[]; void dfs(int now,int pre)
{
for(int t : s[pre]) s[now].insert(__gcd(t,a[now]));
a[now] = __gcd(a[pre],a[now]);
s[now].insert(a[pre]);
for(int t : s[now]) ans[now] = max(ans[now],t);
for(int t : v[now])
{
if(t == pre) continue;
dfs(t,now);
}
} int main()
{
ios::sync_with_stdio();
cin >> n;
for(int i = ;i <= n;i++) cin >> a[i];
for(int i = ;i < n;i++)
{
int x,y;
cin >> x >> y;
v[x].push_back(y);
v[y].push_back(x);
}
a[] = ;
s[].insert();
dfs(,);
for(int i = ;i <= n;i++) cout << ans[i] << " ";
cout << endl;
return ;
}

D.前缀和,二分判断每一位,还要记录位置改变状态。

#include<bits/stdc++.h>
using namespace std; int n,m,cnt[] = {}; int main()
{
ios::sync_with_stdio();
cin >> n >> m;
for(int i = ;i <= n;i++)
{
int x;
cin >> x;
cnt[x] = ;
}
for(int i = ;i <= ;i++) cnt[i] += cnt[i-];
int t = ;
while(m--)
{
int z;
cin >> z;
t ^= z;
int l = ,r = (<<)-;
for(int i = ;i >= ;i--)
{
int tt = t&(<<i),mid = (l+r)/;
if(tt)
{
if(cnt[r]-cnt[mid] < r-mid) l = mid+;
else r = mid;
}
else
{
if(cnt[mid]-(l?cnt[l-]:) < mid-l+) r = mid;
else l = mid+;
}
}
cout << (l^t) << endl;
}
return ;
}

Codeforces_842的更多相关文章

随机推荐

  1. .Net Core Web Api实践(二).net core+Redis+IIS+nginx实现Session共享

    前言:虽说公司app后端使用的是.net core+Redis+docker+k8s部署的,但是微信公众号后端使用的是IIS部署的,虽说公众号并发量不大,但领导还是使用了负载均衡,所以在介绍docke ...

  2. # "可插拔式"组件设计,领略组件开发的奥秘

    从一个 Confirm 组件开始,一步步写一个可插拔式的组件. 处理一个正常的支付流程(比如支付宝购买基金) 点击购买按钮 如果风险等级不匹配则:弹确认框(Confirm) 用户确认风险后:弹出支付方 ...

  3. 解决Maven项目中的无故报错的方法

    解决Eclipse+maven中的无故报错 错误: One or more constraints have not been satisfied. Deployment Assembly跟java版 ...

  4. Fabric1.4:手动启动 first-network 网络(一)

    注意:本文所使用的 fabric 版本为 v1.4.3,与其它版本的网络存在差异. 手动启动 first-network 网络系列分为三部分: 手动启动 first-network 网络(一) 手动启 ...

  5. Scala实践10

    1.模式匹配 模式匹配是一种根据模式检查值的机制.它是switch(Java中语句)的更强大版本,它同样可以用来代替一系列if / else语句. 句法 匹配表达式具有值,match关键字和至少一个c ...

  6. 【PCIE-2】---PCIE配置空间及访问方式简介

    对新手来说,第一步了解PCIE的相关基本概念,第二步了解PCIE配置空间,第三步深入研究PCIE设备枚举方式.本章主要总结第二步的PCIE配置空间 按照国际惯例,先提问题: 1. 什么是PCIE的配置 ...

  7. 引用类型(C# 参考)

    C# 中有两种类型:引用类型和值类型. 引用类型的变量存储对其数据(对象)的引用,而值类型的变量直接包含其数据. 对于引用类型,两种变量可引用同一对象:因此,对一个变量执行的操作会影响另一个变量所引用 ...

  8. 深入理解es6中的Promise

    https://www.jianshu.com/p/9e4af5b77253 https://zhuanlan.zhihu.com/p/30797777 https://segmentfault.co ...

  9. android:整理drawable(余下的)(三)

    前言 随着bitmapDrawabe.nithpatchDrawable 与 shapeDrawable 的整理,接下的就更加需要自己的想象设计一些东西. LayerDrawable 意思是层级性的, ...

  10. kubernetes concepts (一)

    Concepts The Concepts section helps you learn about the parts of the Kubernetes system and the abstr ...