SMU Summer 2023 Contest Round 14
SMU Summer 2023 Contest Round 14
A. Potion-making
就是解一个\(\frac{i}{i + j} = \frac{k}{100}\)方程,然后循环暴力找出答案
#include<bits/stdc++.h>
using i64 = long long;
using namespace std;
typedef pair<i64, i64> PII;
void solve(){
int k;
cin >> k;
for(int i = 1;i <= 100;i ++){
for(int j = 0;j < 100;j ++){
if(i * 100 == k * (i + j)){
cout << i + j << '\n';
return ;
}
}
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int T;
cin >> T;
while(T--){
solve();
}
return 0;
}
B. Permutation Sort
其实就是特判首尾的情况
#include<bits/stdc++.h>
using i64 = long long;
using namespace std;
typedef pair<i64, i64> PII;
void solve(){
int n;
cin >> n;
vector<int> a(n);
for(auto &i : a) cin >> i;
vector<int> b(n);
iota(b.begin(), b.end(),1);
if(a == b){
cout << 0 << '\n';
return ;
}else {
if(a[0] == 1 || a.back() == n)
cout << 1 << '\n';
else if(a[0] == n && a.back() == 1)
cout << 3 << '\n';
else cout << 2 << '\n';
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int T;
cin >> T;
while(T--){
solve();
}
return 0;
}
D. Armchairs
\(dp[i][j]\)表示前\(j\)个椅子放\(i\)个人的最短时间
当前座位为空时,可以放人也可以不放人.
否则,为前一个座位放\(i\)个人的最短时间
#include<bits/stdc++.h>
using i64 = long long;
using namespace std;
typedef pair<i64, i64> PII;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
vector<int> a(n + 1),b(1);
for(int i = 1;i <= n;i ++){
cin >> a[i];
if(a[i] == 1)
b.push_back(i);
}
vector dp(n + 1, vector<int> (n + 1, 0x3f3f3f3f));
for(int i = 0;i <= n;i ++) dp[0][i] = 0;
for(int i = 1;i < b.size();i ++){
for(int j = 1;j <= n;j ++){
if(a[j] == 0){
dp[i][j] = min(dp[i][j - 1], dp[i - 1][j - 1] + abs(b[i] - j));
}else
dp[i][j] = dp[i][j - 1];
}
}
cout << dp[b.size() - 1][n] << '\n';
return 0;
}
SMU Summer 2023 Contest Round 14的更多相关文章
- Codeforces Beta Round #14 (Div. 2)
Codeforces Beta Round #14 (Div. 2) http://codeforces.com/contest/14 A 找最大最小的行列值即可 #include<bits/s ...
- BestCoder Round #14
Harry And Physical Teacher Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Ja ...
- hdu 5066 Harry And Physical Teacher(Bestcoder Round #14)
Harry And Physical Teacher Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Ja ...
- Codeforces Beta Round #14 (Div. 2) D. Two Paths 树形dp
D. Two Paths 题目连接: http://codeforces.com/contest/14/problem/D Description As you know, Bob's brother ...
- Codeforces Beta Round #14 (Div. 2) C. Four Segments 水题
C. Four Segments 题目连接: http://codeforces.com/contest/14/problem/C Description Several months later A ...
- Codeforces Beta Round #14 (Div. 2) B. Young Photographer 水题
B. Young Photographer 题目连接: http://codeforces.com/contest/14/problem/B Description Among other thing ...
- Codeforces Beta Round #14 (Div. 2) A. Letter 水题
A. Letter 题目连接: http://www.codeforces.com/contest/14/problem/A Description A boy Bob likes to draw. ...
- Codeforces Beta Round #14 (Div. 2) D. Two Paths 树的直径
题目链接: http://codeforces.com/contest/14/problem/D D. Two Paths time limit per test2 secondsmemory lim ...
- Codeforces Round #14 D. Two Paths(求树上两条不相交的路径的乘积最大值)
题目链接: http://codeforces.com/problemset/problem/14/D 思路:直接枚举每一天路径的两端,然后求以每一端为树根的树上最长路径,然后相乘就可以了. # ...
- 2014 Benelux Algorithm Programming Contest (BAPC 14)E
题目链接:https://vjudge.net/contest/187496#problem/E E Excellent Engineers You are working for an agency ...
随机推荐
- http/https请求中如何使用Token
简介 Token就像是一个暗号,使用它就可以访问一些需要认证的系统或者服务. 那么,如何在http(s)中使用Token值呢? 使用方法 在http请求的头部字段中添加key-value.key为&q ...
- k8s学习总结之各组件功能及作用的详细介绍
K8S集群架构: 一个K8S集群是由两大部分组成: Master节点和Node节点 一.Master节点主要包括API Server.Scheduler.Controller manager.etcd ...
- Centos 下Rabbit MQ 常用操作指令 汇总
1.rabbitmq 服务的启动停止. service rabbitmq-server start service rabbitmq-server stop 重启命令需要依次执行 stop 再 sta ...
- Filter拦截器从入门到快速上手与Listener监听器概述
前置内容: 会话跟踪技术 目录 1. 过滤器Filter 1.1 Filter快速入门 1.2 Filter执行流程 1.3 Filter使用细节 1.4 案例 2. 监听器Listener概述 2. ...
- SQL注入方法
目录 前言 如何测试与利用注入点 手工 注入思路 工具 sqlmap -r -u -m --level --risk -v -p --threads -batch-smart --os-shell - ...
- SpringBoot 2.5.5整合SpringSecurity+JWT
目录结构 添加依赖 <!-- SpringSecurity --> <dependency> <groupId>org.springframework.boot&l ...
- Mybatis-Plus最优化持久层开发
Mybatis-plus:最优化持久层开发 一:Mybatis-plus快速入门: 1.1:简介: Mybatis-plus(简称MP)是一个Mybatis的增强工具,在mybatis的基础上只做增强 ...
- 让摄像头带上智慧“智驭视界·AIEye”
接上一篇<物联网浏览器(IoTBrowser)-基于计算机视觉开发的应用"智慧眼AIEye">,经过AI的包装很高级,确实很屌炸天. 智驭视界·AIEye 在科技赋能的 ...
- Django DRF @action 装饰器
@action 装饰器在Django REST Framework (DRF) 中非常有用,它可以帮助你在ViewSet中创建自定义的动作,而不仅仅是依赖标准的CRUD操作(Create, Read, ...
- oeasy教您玩转python - 001 - # 换行插入
先跑起来 Python 什么是 Python? Python 很好用 适合初学者 而且在各个领域都很强大 后来居上 上图可以点开 python3 早已有之 最终逆风翻盘 当然 java 也 ...