A - I Scream

根据 奶脂率 和 乳脂率 判断是何种冰淇淋

int main() {
ios_base::sync_with_stdio(false), cin.tie(0);
int a, b;
cin >> a >> b;
a = a + b;
if (a >= 15 && b >= 8) cout << 1;
else if (a >= 10 && b >= 3)
cout << 2;
else if (a >= 3)
cout << 3;
else
cout << 4;
return 0;
}

B - Job Assignment

分开存储,循环判断。如果是同一个人完成任务则总时间累计

int main() {
ios_base::sync_with_stdio(false), cin.tie(0);
vector<int> a, b;
int n, ans = 1e9 + 5;
cin >> n;
a.resize(n);
b.resize(n);
for (int i = 0; i < n; ++i) {
cin >> a[i] >> b[i];
}
for (int i = 0; i < n; ++i)
for (int j = 0; j < n; ++j) {
if (i == j) ans = min(ans, a[i] + b[j]);
else
ans = min(ans, max(a[i], b[j]));
}
cout << ans;
return 0;
}

C - Squared Error

公式推导

\[\begin{gather}
∑_{i = 2}^n∑_{j = 1}^{i - 1}(A_i - A_j)^2 \notag \\
={}& \frac1{2}(∑_{i = 1}^n∑_{j = 1}^{n}(A_i - A_j)^2) & \text{because ($A_i - A_i)^2 = 0$} \\
={}& \frac1{2}(∑_{i = 1}^n∑_{j = 1}^{n}(A_i^2 - A_j^2-2A_iA_j)) \\
={}& \frac1{2}(2N∑_{i = 1}^nA_i^2 - 2∑_{j = 1}^n(A_i∑_{j = 1}^nA_j)) \\
={}& N∑_{i = 1}^nA_i^2 - (∑_{i = 1}^nA_i^2),
\end{gather}
\]

注意用 long long ,溢出了WA了我3次....

using ll = long long;
int main() {
ios_base::sync_with_stdio(false), cin.tie(0);
int n;
cin >> n;
vector<ll> a(n);
ll sos = 0, sum = 0; // sos sum of squares
for (ll &x : a) cin >> x;
for (int i = 0; i < n; i++) {
sos += a[i] * a[i];
sum += a[i];
}
cout << n * sos - sum * sum << endl;
return 0;
}

D - Journey

按题意来即可,注意输出位数来保持精度

int main() {
ios_base::sync_with_stdio(false), cin.tie(0);
int n;
cin >> n;
double cnt = 0.0;
for (int i = 1; i < n; ++i) {
cnt += 1.0 * n / (n - i);
}
cout << setprecision(20) << cnt << "\n";
return 0;
}

E - Mex Min

熟悉的定义...

using ll = long long;
ll n, m, a[5000005], s[5000005], mina, temp = 1;
int main() {
ios_base::sync_with_stdio(false), cin.tie(0);
cin >> n >> m;
for (int i = 1; i <= n; i++) {
cin >> a[i];
if (i <= m) s[a[i]]++;
}
for (int i = 0; i <= n; i++) {
if (s[i] == 0) {
mina = i;
break;
}
}
for (int i = m + 1; i <= n; i++) {
s[a[temp]]--;
s[a[temp + m]]++;
if (a[temp] < mina && s[a[temp]] == 0) {
// cout<<a[temp];
mina = min(mina, a[temp]);
}
temp++;
}
cout << mina;
return 0;
}

F - Digits Paradise in Hexadecimal

不会,先记录下dalao们的解法

__builtin_popcount() 用于计算一个 32 位无符号整数有多少个位为1

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
constexpr int MOD = 1e9 + 7;
long long dp[2][17];
string s;
int n, k, m, a, e;
int main() {
cin >> s >> k;
for (char c : s) {
a = '0' <= c && c <= '9' ? c - '0' : c - 'A' + 10;
rep(i, 16) dp[e][i + 1] =
(dp[e ^ 1][i] * (16 - i) + dp[e ^ 1][i + 1] * (i + 1)) % MOD;
dp[e][1] += m ? 15 : a - 1;
if (m) {
int t = __builtin_popcount(m), b1 = t - __builtin_popcount(m >> a);
dp[e][t + 1] += a - b1;
dp[e][t] += b1;
}
m |= 1 << a;
e ^= 1;
}
dp[e ^ 1][__builtin_popcount(m)] += 1;
cout << dp[e ^ 1][k] % MOD << endl;
}

AtCoder Beginner Contest 194 Editorial的更多相关文章

  1. AtCoder Beginner Contest 194

    A I Scream int main() { IOS; int a, b; cin >> a >> b; if(a + b >= 15 && b > ...

  2. AtCoder Beginner Contest 100 2018/06/16

    A - Happy Birthday! Time limit : 2sec / Memory limit : 1000MB Score: 100 points Problem Statement E8 ...

  3. AtCoder Beginner Contest 052

    没看到Beginner,然后就做啊做,发现A,B太简单了...然后想想做完算了..没想到C卡了一下,然后还是做出来了.D的话瞎想了一下,然后感觉也没问题.假装all kill.2333 AtCoder ...

  4. AtCoder Beginner Contest 053 ABCD题

    A - ABC/ARC Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Smeke has ...

  5. AtCoder Beginner Contest 136

    AtCoder Beginner Contest 136 题目链接 A - +-x 直接取\(max\)即可. Code #include <bits/stdc++.h> using na ...

  6. AtCoder Beginner Contest 137 F

    AtCoder Beginner Contest 137 F 数论鬼题(虽然不算特别数论) 希望你在浏览这篇题解前已经知道了费马小定理 利用用费马小定理构造函数\(g(x)=(x-i)^{P-1}\) ...

  7. AtCoder Beginner Contest 076

    A - Rating Goal Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Takaha ...

  8. AtCoder Beginner Contest 079 D - Wall【Warshall Floyd algorithm】

    AtCoder Beginner Contest 079 D - Wall Warshall Floyd 最短路....先枚举 k #include<iostream> #include& ...

  9. AtCoder Beginner Contest 064 D - Insertion

    AtCoder Beginner Contest 064 D - Insertion Problem Statement You are given a string S of length N co ...

  10. AtCoder Beginner Contest 075 D - Axis-Parallel Rectangle【暴力】

    AtCoder Beginner Contest 075 D - Axis-Parallel Rectangle 我要崩溃,当时还以为是需要什么离散化的,原来是暴力,特么五层循环....我自己写怎么都 ...

随机推荐

  1. 超详细的Mysql锁 实战分析,你想知道的都在这里~

    1.mysql回表查询 在这里提起主要是用于说明mysql数据和索引的结构,有助于理解后续加锁过程中的一些问题. mysql索引结构和表数据结构是相互独立的,根据索引查询,只能找到索引列和主键聚簇索引 ...

  2. New Type Functions/Utilities for Dealing with Ranges in C++20

    Generic Types of Ranges   类型萃取从字面意思上来说其实就是帮助我们挑选某个对象的类型,筛选特定的对象来做特定的事.可以先来回顾一下以前的写法. #include <ve ...

  3. excel表格怎么设置数据超链接?

    在Excel表格中,可以设置超链接来快速导航到其他单元格.工作表.文件.网页等.下面我将详细介绍如何设置数据超链接. 1. 在Excel表格中选择要添加超链接的单元格或文本. 2. 使用鼠标右键点击选 ...

  4. 吉特日化MES-业务架构第一版图

  5. CompletableFuture入门

    CompletableFuture入门 1.Future vs CompletableFuture 1.1 准备工作 先定义一个工具类 import java.nio.file.Files; impo ...

  6. 牛客小白月赛2 E题 是是非非 (尼姆博弈)

    题目链接:https://www.nowcoder.com/acm/contest/86/E 解题思路:由尼姆博弈我们可以知道,如果所有堆的石子数量异或为0,那么先手必败,否则先手必胜. 由异或我们可 ...

  7. SpringBoot对象拷贝

    目录 概述 定义实体类 Car size carInfo 造测试数据 Spring BeanUtils Apache BeanUtils Cglib BeanCopier MapStruct 性能测试 ...

  8. 【笔记】 springCloud-configServer配置中心

    当然第一步还是得要了解啦! 介绍 做项目, 那么就少不了配置微服务架构中,配置文件众多,各个服务的配置文件也有可能不一样, Spring为我们提供了相应的配置中心组件--Spring Cloud co ...

  9. springboot--ActiveMQ--消息队列

    ActiveMQ远程消息队列 一.我们创建springboot项目工程 二.创建完毕我们简单介绍 activeMQ 1.概述 消息中间件可以理解成就是一个服务软件,保存信息的容器,比如生活中的快递云柜 ...

  10. (转)Harbor 启用镜像扫描功能方法

    A demo environment with the latest Harbor stable build installed. For additional information please ...