比赛链接: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)的更多相关文章

  1. Atcoder Beginner Contest 147C(状态压缩)

    最多15个人,用N个二进制的数字表示每个人的状态,然后检验.这串数字相当于已经把这些人的状态定了下来,如果和输入的情况不符则这串数字不正确,直接忽略,因为枚举了所有的情况,所以总有正确的,不必在错误的 ...

  2. AtCoder Beginner Contest 254(D-E)

    Tasks - AtCoder Beginner Contest 254 D - Together Square 题意: 给定一个N,找出所有不超过N的 ( i , j ),使得( i * j )是一 ...

  3. AtCoder Beginner Contest 086 (ABCD)

    A - Product 题目链接:https://abc086.contest.atcoder.jp/tasks/abc086_a Time limit : 2sec / Memory limit : ...

  4. AtCoder Beginner Contest 085(ABCD)

    A - Already 2018 题目链接:https://abc085.contest.atcoder.jp/tasks/abc085_a Time limit : 2sec / Memory li ...

  5. AtCoder Beginner Contest 084(AB)

    A - New Year 题目链接:https://abc084.contest.atcoder.jp/tasks/abc084_a Time limit : 2sec / Memory limit  ...

  6. AtCoder Beginner Contest 083 (AB)

    A - Libra 题目链接:https://abc083.contest.atcoder.jp/tasks/abc083_a Time limit : 2sec / Memory limit : 2 ...

  7. AtCoder Beginner Contest 264(D-E)

    D - "redocta".swap(i,i+1) 题意: 给一个字符串,每次交换相邻两个字符,问最少多少次变成"atcoder" 题解: 从左到右依次模拟 # ...

  8. Atcoder Beginner Contest 121D(异或公式)

    #include<bits/stdc++.h>using namespace std;int main(){    long long a,b;    cin>>a>&g ...

  9. Atcoder Beginner Contest 156E(隔板法,组合数学)

    #define HAVE_STRUCT_TIMESPEC #include<bits/stdc++.h> using namespace std; ; ; long long fac[N] ...

  10. Atcoder Beginner Contest 155E(DP)

    #definde HAVE_STRUCT_TIMESPEC #include<bits/stdc++.h> using namespace std; ]; int main(){ ios: ...

随机推荐

  1. 报错:bs4.FeatureNotFound: Couldn't find a tree builder with the features you requ

    安装 pip3 install lxml 即可

  2. QA12更改使用决策时自动转至长文本并报错 上载附件 Word2007template.dotm

    *&---------------------------------------------------------------------**& Report Z_SCR_WORD ...

  3. Echarts图表基本参数设置说明

    ECharts 是一款强大的数据可视化库,可以通过 JavaScript 构建交互式和动态的图表.在使用 ECharts 进行图表绘制时,我们可以通过设置各种参数来达到我们想要的效果.下面是对 ECh ...

  4. 【scikit-learn基础】--『数据加载』之样本生成器

    除了内置的数据集,scikit-learn还提供了随机样本的生成器.通过这些生成器函数,可以生成具有特定特性和分布的随机数据集,以帮助进行机器学习算法的研究.测试和比较. 目前,scikit-lear ...

  5. [ABC268G] Random Student ID

    Problem Statement Takahashi Elementary School has $N$ new students. For $i = 1, 2, \ldots, N$, the n ...

  6. C#_Win32_PInvoke源码生成器

    介绍 一个源代码生成器,用于向 C#项目添加一组用户定义的 Win32 P/Invoke 方法和相关的类型. 链接地址: https://github.com/microsoft/CsWin32 还在 ...

  7. Scrapy-settings.py常规配置

    # Scrapy settings for scrapy_demo project # # For simplicity, this file contains only settings consi ...

  8. parameterType的用法

    在mybatis映射接口的配置中,有select,insert,update,delete等元素都提到了parameterType的用法,parameterType为输入参数,在配置的时候,配置相应的 ...

  9. 复现YOLO5所遇到的问题

    一. 解决方案: 由于没有影响模型继续运行,理解为简单的warning.根据查询问题,推断是由于 pytorch和torchvision的版本原因导致的. 二. 解决方案: 由于没有影响模型继续运行, ...

  10. Ubuntu修改root可以远程ssh

    默认情况下,Ubuntu系统不允许root远程登录,新建的系统root密码为随机密码,你不会知道首次ssh登录需要用自建用户远程登录,登录后提示如下: seafile@seafile:~$  是以 ~ ...