AtCoder Beginner Contest 194 Editorial
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
公式推导
∑_{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的更多相关文章
- AtCoder Beginner Contest 194
A I Scream int main() { IOS; int a, b; cin >> a >> b; if(a + b >= 15 && b > ...
- AtCoder Beginner Contest 100 2018/06/16
A - Happy Birthday! Time limit : 2sec / Memory limit : 1000MB Score: 100 points Problem Statement E8 ...
- AtCoder Beginner Contest 052
没看到Beginner,然后就做啊做,发现A,B太简单了...然后想想做完算了..没想到C卡了一下,然后还是做出来了.D的话瞎想了一下,然后感觉也没问题.假装all kill.2333 AtCoder ...
- AtCoder Beginner Contest 053 ABCD题
A - ABC/ARC Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Smeke has ...
- AtCoder Beginner Contest 136
AtCoder Beginner Contest 136 题目链接 A - +-x 直接取\(max\)即可. Code #include <bits/stdc++.h> using na ...
- AtCoder Beginner Contest 137 F
AtCoder Beginner Contest 137 F 数论鬼题(虽然不算特别数论) 希望你在浏览这篇题解前已经知道了费马小定理 利用用费马小定理构造函数\(g(x)=(x-i)^{P-1}\) ...
- AtCoder Beginner Contest 076
A - Rating Goal Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Takaha ...
- AtCoder Beginner Contest 079 D - Wall【Warshall Floyd algorithm】
AtCoder Beginner Contest 079 D - Wall Warshall Floyd 最短路....先枚举 k #include<iostream> #include& ...
- AtCoder Beginner Contest 064 D - Insertion
AtCoder Beginner Contest 064 D - Insertion Problem Statement You are given a string S of length N co ...
- AtCoder Beginner Contest 075 D - Axis-Parallel Rectangle【暴力】
AtCoder Beginner Contest 075 D - Axis-Parallel Rectangle 我要崩溃,当时还以为是需要什么离散化的,原来是暴力,特么五层循环....我自己写怎么都 ...
随机推荐
- 匿名远程启动jenkins的job
安装jenkins插件Build Authorization Token Root job配置中的构建触发器,勾选触发远程构建,输入要用的令牌,如soul 通过jenkins地址调用触发 非参数化jo ...
- 马云说的AI电商时代是什么
这两天非常火的就是马老师说的,我们已经进入了AI的电商时代.相信电商时代大家很容易理解,换一个简单的方式来说就是网上购物. AI相信大家已经很熟悉了,就是人工智能.早在十年前其实已经有AI人工智能的概 ...
- SpringBoot整合Liquibase
1.是什么? Liquibase官网 Liquibase是一个开源的数据库管理工具,可以帮助开发人员管理和跟踪数据库变更.它可以与各种关系型数据库和NoSQL数据库一起使用,并提供多种数据库任务自动化 ...
- python学习笔记:python的字符串拼接效率分析
问题的起因是因为在做LeetCode5714题的时候,对于字符串拼接使用了 ans = ans+s[i] 提交后超时了,改成 ans+=s[i] 就可以通过了,而且用c++好像也有这个问题,在此记录一 ...
- XILINX HLS 入坑记录 之 写RAM 综合出 读取+写入Ram
最近使用 Xilinx HLS 来开发 算法的IPcore,使用的Vitis 2021,发现光是 EDA 工具就存在很多的bug,比如: 1.经常C综合 停留在 Using flow_target ' ...
- 【Python】【ChatGPT】本地部署ChatGPT学习记录
学习一下GPT项目的相关使用和部署 一.GPT4ALL模型 Github:https://github.com/nomic-ai/gpt4all GPT4ALL项目部署简易,但是在运行体验上一般,并且 ...
- Volcano 原理、源码分析(一)
0. 总结前置 1. 概述 2. Volcano 核心概念 2.1 认识 Queue.PodGroup 和 VolcanoJob 2.2. Queue.PodGroup 和 VolcanoJob 的关 ...
- 【Azure APIM】APIM 策略语句如何来设置多个Cookie值让浏览器保存
问题描述 在APIM的 <return-response> 策略中,设置Cookie值,因为需要设置多个Cookie值,使用下面两种方式都只能保存一个Cookie值: 方式一:把多个coo ...
- 关于helloworld
我们的helloworld是从一个源程序开始的,该源程序由程序员通过编译器创建并保存的文件,文件名就是hello.c.这个hello.c的源程序,实际上是有0和1组成的序列.每一个0和1都成为一位,这 ...
- JavaFx之SceneBuilder添加其他依赖库(十六)
JavaFx之SceneBuilder添加其他依赖库(十六) Could not open 'xxxxx.jar' Open operation has failed. Make sure that ...