Codeforces Round 886 (Div. 4)
Dashboard - Codeforces Round 886 (Div. 4) - Codeforces
A. To My Critics
判断任意两个大于10即可
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 2e5 + 10;
signed main() {
ios::sync_with_stdio(false);cin.tie(nullptr);
int a,b,c;
cin >> a >> b >> c;
if(a + b >= 10 || b + c >= 10|| a + c >= 10)
cout << "YES" << endl;
else
cout << "NO" << endl;
return 0;
}
B. Ten Words of Wisdom
把质量大于10的pass掉,剩下的排个序即可
#include <bits/stdc++.h>
#define int long long
using namespace std;
typedef pair<int,int> PII;
signed main() {
ios::sync_with_stdio(false);cin.tie(nullptr);
int T;
cin >> T;
while(T--){
int n;
cin >> n;
vector<PII> a;
for(int i = 1, x,y;i <= n;i ++){
cin >> x >> y ;
if(x > 10) continue;
else
a.emplace_back(i,y);
}
sort(a.begin(),a.end(),[](PII x,PII y){
return x.second > y.second;
});
cout << a.front().first << endl;
}
return 0;
}
C. Word on the Paper
模拟题,因为它没有逆字符串,所以遇到字符就加上即可
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
ios::sync_with_stdio(false);cin.tie(nullptr);
int T;
cin >> T;
while(T--){
vector<string> g(8);
for(int i = 0;i < 8;i ++)
cin >> g[i];
string ans = "";
for(int i = 0;i < 8;i ++){
for(int j = 0;j < 8;j ++){
if(g[i][j] == '.')
continue;
else
ans += g[i][j];
}
}
cout << ans << endl;
}
return 0;
}
D. Balanced Round
就是找连续的数的差值在k的范围内的有多少,找到最大的之后其余的数就是至少要删掉的了
#include <bits/stdc++.h>
#define int long long
using namespace std;
typedef pair<int,int> PII;
signed main() {
ios::sync_with_stdio(false);cin.tie(nullptr);
int T;
cin >> T;
while(T--){
int n,k;
cin >> n >> k;
vector<int> a(n);
for(auto &i : a) cin >> i;
sort(a.begin(),a.end());
int ans = 0, now = 1;
for(int i = 0;i < n - 1;i ++ ){
if(a[i + 1] - a[i] <= k){
now++;
}else{
ans = max(now,ans);
now = 1;
}
}
ans = max(ans, now);
cout << n - ans << endl;
}
return 0;
}
E. Cardboard for Pictures
根据题意就是求\(\sum\limits_{i=1}^{n} (2 \times w + s_i)^2 = C\)这样一个公式中的\(w\)存在的,答案存在递增性,于是我们可以用二分答案来做,每次判断是否符合条件在计算过程中,可能会爆\(long long\),需要开__int128,如果你是只要大于就提前返回的话就不用开,另外因为要开方,所以\(w\)最大只能取\(1e9\).
#include <bits/stdc++.h>
#define int long long
using namespace std;
typedef pair<int,int> PII;
signed main() {
ios::sync_with_stdio(false);cin.tie(nullptr);
int T;
cin >> T;
while(T--){
int n,c;
cin >> n >> c;
vector<int> s(n);
for(auto &i : s) cin >> i;
auto check = [&](int x){
__int128 ans = 0;
for(auto i : s){
ans += ((__int128)2 * x + i) * ((__int128)2 * x + i);
if(ans > c) return true;
}
return ans > c;
};
int l = 1, r = 1e9;
while(l <= r){
int mid = (l + r) >> 1;
if(check(mid))
r = mid - 1;
else
l = mid + 1;
}
cout << l - 1 << endl;
}
return 0;
}
F. We Were Both Children
用一个桶\(s\)去维护每只青蛙能跳到的最大倍数,暴力枚举每个\(a_i\)能贡献到的最大的\(s_j\),即\(j\)是\(a_i\)的倍数,最后在桶里找一个最大值即可\(\mathcal{O}(nlogn)\)
#include <bits/stdc++.h>
#define int long long
using namespace std;
typedef pair<int,int> PII;
signed main() {
ios::sync_with_stdio(false);cin.tie(nullptr);
int T;
cin >> T;
while(T--){
int n,c;
cin >> n ;
vector<int> s(n + 1);
for(int i = 0;i < n;i ++) {
cin >> c;
if(c <= n)
s[c] ++;
}
for(int i = n;i >= 1; i--){
for(int j = 2 * i; j <= n;j += i)
s[j] += s[i];
}
cout << *max_element(s.begin(),s.end()) << endl;
}
return 0;
}
G. The Morning Star
可以用map来维护四个桶,记录四个方向,另外四个方向都是在同一条直线上,所以我计算出结果后乘2即可,对于\(N,S,x相同,W,E,y相同,NE,SW,x - y相同,SE,NW,x+y相同\),将星星个数全部累加起来即可
#include <bits/stdc++.h>
#define int long long
using namespace std;
typedef pair<int,int> PII;
signed main() {
ios::sync_with_stdio(false);cin.tie(nullptr);
int T;
cin >> T;
while(T--){
int n;
cin >> n;
map<int,int> mp[4];
int ans = 0;
for(int i = 0,x,y;i < n;i ++){
cin >> x >> y;
ans += mp[0][x] ++ ;
ans += mp[1][y] ++ ;
ans += mp[2][x - y] ++ ;
ans += mp[3][y + x] ++ ;
}
cout << ans * 2 << endl;
}
return 0;
}
Codeforces Round 886 (Div. 4)的更多相关文章
- Codeforces Round #366 (Div. 2) ABC
Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...
- Codeforces Round #354 (Div. 2) ABCD
Codeforces Round #354 (Div. 2) Problems # Name A Nicholas and Permutation standard input/out ...
- Codeforces Round #368 (Div. 2)
直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...
- cf之路,1,Codeforces Round #345 (Div. 2)
cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅..... ...
- Codeforces Round #279 (Div. 2) ABCDE
Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems # Name A Team Olympiad standard input/outpu ...
- Codeforces Round #262 (Div. 2) 1003
Codeforces Round #262 (Div. 2) 1003 C. Present time limit per test 2 seconds memory limit per test 2 ...
- Codeforces Round #262 (Div. 2) 1004
Codeforces Round #262 (Div. 2) 1004 D. Little Victor and Set time limit per test 1 second memory lim ...
- Codeforces Round #371 (Div. 1)
A: 题目大意: 在一个multiset中要求支持3种操作: 1.增加一个数 2.删去一个数 3.给出一个01序列,问multiset中有多少这样的数,把它的十进制表示中的奇数改成1,偶数改成0后和给 ...
- Codeforces Round #268 (Div. 2) ABCD
CF469 Codeforces Round #268 (Div. 2) http://codeforces.com/contest/469 开学了,时间少,水题就不写题解了,不水的题也不写这么详细了 ...
- 贪心+模拟 Codeforces Round #288 (Div. 2) C. Anya and Ghosts
题目传送门 /* 贪心 + 模拟:首先,如果蜡烛的燃烧时间小于最少需要点燃的蜡烛数一定是-1(蜡烛是1秒点一支), num[g[i]]记录每个鬼访问时已点燃的蜡烛数,若不够,tmp为还需要的蜡烛数, ...
随机推荐
- CSDN 大规模抓取 GitHub 上的项目到 GitCode,伪造开发者主页引公愤
事件起因 CSDN旗下的GitCode最近因为一种极其不道德的行为引起了开发者的广泛愤怒和抗议.CSDN在没有通知或征求开发者同意的情况下,悄悄地将大量GitHub上的开源项目搬运到了其自己的GitC ...
- Vs生成后 自动压缩 删除多余xml
setlocal enabledelayedexpansionset ProjectName=$(ProjectName)del /s /q /f "$(ProjectDir)bin\Deb ...
- SNAT,DNAT以及REDIRECT转发详解
最近负责的其中一个项目的服务器集群出现了点网络方面的问题,在处理过程当中又涉及到了防火墙相关的知识和命令,想着有一段时间没有复习这部分内容了,于是借着此次机会复写了下顺便将本次复习的一些内容以博客的形 ...
- [UG 二次开发 PYTHON] 添加螺纹规格
NX 1988 系列 在添加螺纹特征时,不能自定义螺纹规格, 从网上找到的资料上讲,改一个XML文件,在文件中添加自定义的螺纹规格,从而实现需要的效果. 自己写了一个小程序,方便手动添加螺纹规格. 效 ...
- Qt实现汽车仪表盘
在UI界面显示中,仪表盘的应用相对比较广泛,经常用于显示速度值,电压电流值等等,最终实现效果如下动态图片(文末提供给源工程下载): 主要包含以下绘制步骤: 绘制画布 /* * 绘制画布 */ void ...
- P5494 题解
来一发 \(O(\log n)\) 线性空间的解法. 考虑通过只维护线段树叶子节点的虚树的方法压缩空间,考虑记录下每个节点的编号,然后通过异或完求最低位的 \(1\) 的方式求出 LCA 的深度,然后 ...
- Nuxt3 的生命周期和钩子函数(十一)
title: Nuxt3 的生命周期和钩子函数(十一) date: 2024/7/5 updated: 2024/7/5 author: cmdragon excerpt: 摘要:本文详细介绍了Nux ...
- windows server + iis 部署若伊前端vue项目
一.背景说明 工作原因,一直使用若伊前后端分离版框架进行二次开发.客户的服务器多数为windows server系统,少部分为linux系统.过去一直是使用nginx进行前端的部署,nginx的代理功 ...
- v-if 和 v-show 有什么区别?
v-if 是真正的条件渲染,会控制这个 DOM 节点的存在与否.因为它会确保在切换过程中条件块内的事件监听器和子组件适当地被销毁和重建:也是惰性的:如果在初始渲染时条件为假,则什么也不做--直到条件第 ...
- 【实操记录】MySQL主从配置
本文使用MySQL原生支持的主从同步机制,详细记录了配置步骤及运维操作方法,可供大家直接参考.使用. 本文假设已经部署了两台主机的MySQL软件,且数据库服务正常,详细部署步骤可本站搜索:" ...
