AtCoder Beginner Contest 166 (A~E)
比赛链接:Here
AB水题
C - Peaks
题意:
- 给出 \(n\) 个观察台的高度,以及 \(m\) 条边,定义“好观察台”:比所有直接相连的观测台都高
思路:
因为道路是双向的,互相判断一下即可
a &= bool 这个写法学习了
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
int n, m; cin >> n >> m;
vector<int>h(n), st(n, 1);
for (int &i : h) cin >> i;
while (m--) {
int a, b;
cin >> a >> b, a -= 1, b -= 1;
st[a] &= h[a] > h[b];
st[b] &= h[b] > h[a];
}
int cnt = 0;
for (int i = 0; i < n; ++i) cnt += st[i];
cout << cnt;
}
D - I hate Factorization
题意:
- 给出 \(X(\le1e9)\) 请问存在 \((A,B)\) 使得 \(A^5-B^5 =X\) 吗
思路:
因为 A,B可取负值,而且数据范围挺大的,说明应该有技巧
实际写了一下数据发现 \(A,B\) 取值范围应该在 \([-1000,1000]\) 之中,而且一定存在(证明不提供)
那么直接枚举就好了
ll fac(ll x) {return x * x * x * x * x;}
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
ll n; cin >> n;
for (ll i = -1000; i <= 1000; ++i) {
ll y = fac(i) + n;
for (ll j = -1000; j <= 1000; ++j)
if (fac(j) == y) {
return printf("%lld %lld", j, i), 0;
}
}
}
E - This Message Will Self-Destruct in 5s
题意:
给出一个长度为 n 的序列 h,
求问有多少组不同的无序数对 \((i,j)\) 使得 \(|i-j| = h_i + h_j\)
思路:
思维题,题意是找数对 \((i,j)\) 使得 \(|i-j| = h_i + h_j\) ,我们不妨设讠<j,移项得:a-j=-0-,很容易想到用map存数,每次更新答案即可
我们可以设 \(i<j\) 简单移项后 map 存数即可(在ABC里做过类似的了)
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
int n; cin >> n;
int a[n + 1];
ll cnt = 0;
map<int, int>mp;
for (int i = 1; i <= n; ++i) {
cin >> a[i];
cnt += mp[a[i] - i];
mp[-a[i] - i] += 1;
}
cout << cnt ;
}
AtCoder Beginner Contest 166 (A~E)的更多相关文章
- Atcoder Beginner Contest 147C(状态压缩)
最多15个人,用N个二进制的数字表示每个人的状态,然后检验.这串数字相当于已经把这些人的状态定了下来,如果和输入的情况不符则这串数字不正确,直接忽略,因为枚举了所有的情况,所以总有正确的,不必在错误的 ...
- AtCoder Beginner Contest 254(D-E)
Tasks - AtCoder Beginner Contest 254 D - Together Square 题意: 给定一个N,找出所有不超过N的 ( i , j ),使得( i * j )是一 ...
- AtCoder Beginner Contest 086 (ABCD)
A - Product 题目链接:https://abc086.contest.atcoder.jp/tasks/abc086_a Time limit : 2sec / Memory limit : ...
- AtCoder Beginner Contest 085(ABCD)
A - Already 2018 题目链接:https://abc085.contest.atcoder.jp/tasks/abc085_a Time limit : 2sec / Memory li ...
- AtCoder Beginner Contest 084(AB)
A - New Year 题目链接:https://abc084.contest.atcoder.jp/tasks/abc084_a Time limit : 2sec / Memory limit ...
- AtCoder Beginner Contest 083 (AB)
A - Libra 题目链接:https://abc083.contest.atcoder.jp/tasks/abc083_a Time limit : 2sec / Memory limit : 2 ...
- AtCoder Beginner Contest 264(D-E)
D - "redocta".swap(i,i+1) 题意: 给一个字符串,每次交换相邻两个字符,问最少多少次变成"atcoder" 题解: 从左到右依次模拟 # ...
- Atcoder Beginner Contest 121D(异或公式)
#include<bits/stdc++.h>using namespace std;int main(){ long long a,b; cin>>a>&g ...
- Atcoder Beginner Contest 156E(隔板法,组合数学)
#define HAVE_STRUCT_TIMESPEC #include<bits/stdc++.h> using namespace std; ; ; long long fac[N] ...
- Atcoder Beginner Contest 155E(DP)
#definde HAVE_STRUCT_TIMESPEC #include<bits/stdc++.h> using namespace std; ]; int main(){ ios: ...
随机推荐
- 手把手教Electron+vue,打包vue项目,打包成桌面程序。
1.现如今前端框架数不胜数,尤其是angular.vue吸引一大批前端开发者,在这个高新技术快速崛起的时代,自然少不了各种框架的结合使用.接下来是介绍electron+vue的结合使用. 2.Elec ...
- cyclone3内部资源
CycloneIII内部资源概述 目录 CycloneIII内部资源概述 Logic Elements and Logic Array Blocks(逻辑元件和逻辑阵列块) LE LAB LAB In ...
- UNCTF-Crypto wp
2020年 easy_rsa 题目 from Crypto.Util import number import gmpy2 from Crypto.Util.number import bytes_t ...
- 分享一个 asp.net core 多文件分块同时上传的组件
分享一个可多个文件同时上传.断点续传,并实时反馈上传进度的 Asp.Net core 组件. 服务器端 引用 nuget 包:JMS.FileUploader.AspNetCore 然后启用上传组件: ...
- 2023年奔走的总结---吉特日化MES 制药项目 篇二
书接上文,反正今年也就折腾一下了,索性好好整理一下思绪写写文章,当做工作笔记.今年工作中遇到了各种各样的事情,可能是由于今年项目压力像无头苍蝇一样瞎撞,也打发一下按耐不住的心.本篇将记录一下<吉 ...
- i-MES生产制造管理系统-SMT物料防错与追溯
说起 SMT,相信大家或多或少都有一些了解,主要是用来贴片的,简单点说就是给空白的 PCB 板贴上一些元器件,比如二极管.IC.电阻等等各种电子元器件,以前客户对这些元器件物料的追溯管控的并不严格,只 ...
- 解决Tensorflow2.0出现:AttributeError: module 'tensorflow' has no attribute 'get_default_graph'的问题
问题描述 在使用tensorflow2.0时,遇到了这个问题: AttributeError: module 'tensorflow' has no attribute 'get_default_gr ...
- Mybatis-Flex之基础搭建
1.是什么? MyBatis-Flex 是一个优雅的 MyBatis 增强框架,它非常轻量.同时拥有极高的性能与灵活性.我们可以轻松的使用 Mybaits-Flex 链接任何数据库,其内置的Query ...
- Python 中如何编写类型提示
哈喽大家好,我是咸鱼 我们知道 Python 是一门具有动态特性的语言,在编写 Python 代码的时候不需要显式地指定变量的类型 这样做虽然方便,但是降低了代码的可阅读性,在后期 review 代码 ...
- java通过url得到文件对象(支持http和https)
文字标题:java通过url得到文件对象(支持http和https) 作者:锅巴 1.场景:通过一个url地址来得到一个文件,此方式就是通过一个url将文件下载到本地的临时文件,直接上代码 /** * ...