23暑假友谊赛No.2
23暑假友谊赛No.2
A-雨_23暑假友谊赛No.2 (nowcoder.com)
#include <bits/stdc++.h>
using namespace std;
signed main() {
ios::sync_with_stdio(false);cin.tie(nullptr);
int a,b,c,d,x;
cin >> a >> b >> c >> d >> x;
cout << (a > x ? 0 : x - a) << ' ' << (b > x ? 0 : x - b) << ' ' << (c > x ? 0 : x - c)<< " " << (d > x ? 0 : x - d);
return 0;
}
B-吻_23暑假友谊赛No.2 (nowcoder.com)
啊,忘了加后取模,我真傻,真的.
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
ios::sync_with_stdio(false);cin.tie(nullptr);
const int mod = 998244353;
int n;
cin >> n;
n %= mod;
cout << (n % mod + n % mod * (n - 1) % mod) % mod << endl;
return 0;
}
C-失_23暑假友谊赛No.2 (nowcoder.com)
模拟
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
ios::sync_with_stdio(false);cin.tie(nullptr);
string s;
int n;
cin >> s >> n;
vector<string> ans(n);
for(auto &i : ans) cin >> i;
vector<int> k(n);
for(int i = 0;i < n;i ++){
if(ans[i].size() != s.size()){
k[i] = 0;
}else{
for(int j = 0;j < s.size();j ++)
k[i] += (ans[i][j] == s[j]);
}
}
vector<string> res;
int m = *max_element(k.begin(),k.end());
for(int i = 0;i < n;i ++){
if(k[i] == m)
res.emplace_back(ans[i]);
}
sort(res.begin(),res.end());
for(auto i : res)
cout << i << endl;
return 0;
}
D-吹_23暑假友谊赛No.2 (nowcoder.com)(动态规划)
\(dp[i][0/1]\)表示当前数为1或原数时的最大可爱值.
若当前数为1,则它的最大值为它左边为1的可爱值或为原数时加上原数 - 1的可爱值
若当前数为原数,则它的最大值为左边为1加上当前数 - 1 或 为 原数时加上原数与当前数的差的绝对值
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
ios::sync_with_stdio(false);cin.tie(nullptr);
int n;
cin >> n;
vector<int> a(n);
for(auto &i : a) cin >>i ;
vector dp(n,vector<int>(2,0));
for(int i = 1;i < n;i ++){
dp[i][0] = max(dp[i - 1][0],dp[i - 1][1] + abs(a[i - 1] - 1)) ;
dp[i][1] = max(dp[i - 1][0] + abs(a[i] - 1), dp[i - 1][1] + abs(a[i - 1] - a[i]));
}
cout << max(dp[n - 1][0],dp[n - 1][1]) << endl;
return 0;
}
E-唤_23暑假友谊赛No.2 (nowcoder.com)
首先边长为4,5,6的纸片都各需要一个正方形边框,而一个正方形边框可以装4个边长为3的纸片,边长为2和1的纸片可以放在这些纸片的空隙中,需要特殊处理.
一个边长为4的纸片可以放5个边长为2的,四个边长为3的纸片放不了边长为2的,一个边长为3的可以放5个,二个边长为3的可以放3个,三个边长为3的可以放1个,处理出当前有多少空隙可以放边长为2的纸片后继续处理边长为1的.
边长为1的只要看当前的边框面积减去已放入的纸片的面积,剩下的面积都能放边长为1的,比较一下看看还需不需要再继续加边框即可
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
ios::sync_with_stdio(false);cin.tie(nullptr);
int T;
cin >> T;
while(T--){
int s;
cin >> s;
int s3[] = {0,5,3,1};
vector<int> k(7);
for(int i = 1;i <= 6;i ++) cin >> k[i];
int ans = 0;
ans += k[6] + k[5] + k[4] + (k[3] + 3) / 4;
int num2 = 5 * k[4] + s3[k[3] % 4];
if(k[2] > num2)
ans += (k[2] - num2 + 8) / 9;
int sum = ans * 36 - k[6] * 36 - k[5] * 25 - k[4] * 16 - k[3] * 9 - k[2] * 4;
if(k[1] > sum)
ans += (k[1] - sum + 35) / 36;
cout << (ans > s ? "No" : "Yes") << endl;
}
return 0;
}
23暑假友谊赛No.2的更多相关文章
- 合肥学院ACM集训队第一届暑假友谊赛 B FYZ的求婚之旅 D 计算机科学家 F 智慧码 题解
比赛网址:https://ac.nowcoder.com/acm/contest/994#question B FYZ的求婚之旅 思路: 然后用快速幂即可. 细节见代码: #include <i ...
- 暑假训练round 3 题解
今天做题运气出奇的好,除了几处小错误调试之后忘记改掉了……最后还AK了……虽然题目不难,学长也说是福利局,但是对个人的鼓励作用还是挺大的……至此暑假训练就结束了,也算没有遗憾……. 题解如下: Pro ...
- 20172305 暑假作业 之 TimeCalculate & Save Iron Man
20172305 暑假作业 之 TimeCalculate & Save Iron Man TimeCalculate 项目介绍 项目名称: TimeCalculate 项目简介: 本项目基于 ...
- STL 入门 (17 暑假集训第一周)
快速全排列的函数 头文件<algorithm> next_permutation(a,a+n) ---------------------------------------------- ...
- [置顶] 2013_CSUST暑假训练总结
2013-7-19 shu 新生训练赛:母函数[转换成了背包做的] shuacm 题目:http://acm.hdu.edu.cn/diy/contest_show.php?cid=20083总结:h ...
- 2014年暑假c#学习笔记目录
2014年暑假c#学习笔记 一.C#编程基础 1. c#编程基础之枚举 2. c#编程基础之函数可变参数 3. c#编程基础之字符串基础 4. c#编程基础之字符串函数 5.c#编程基础之ref.ou ...
- Java开发中的23种设计模式详解
[放弃了原文访问者模式的Demo,自己写了一个新使用场景的Demo,加上了自己的理解] [源码地址:https://github.com/leon66666/DesignPattern] 一.设计模式 ...
- ILJMALL project过程中遇到Fragment嵌套问题:IllegalArgumentException: Binary XML file line #23: Duplicate id
出现场景:当点击"分类"再返回"首页"时,发生error退出 BUG描述:Caused by: java.lang.IllegalArgumentExcep ...
- CSharpGL(23)用ComputeShader实现一个简单的ParticleSimulator
CSharpGL(23)用ComputeShader实现一个简单的ParticleSimulator 我还没有用过Compute Shader,所以现在把红宝书里的例子拿来了,加入CSharpGL中. ...
- ABP(现代ASP.NET样板开发框架)系列之23、ABP展现层——异常处理
点这里进入ABP系列文章总目录 基于DDD的现代ASP.NET开发框架--ABP系列之23.ABP展现层——异常处理 ABP是“ASP.NET Boilerplate Project (ASP.NET ...
随机推荐
- Codeforces Round #243 (Div. 2) Problem B - Sereja and Mirroring 题解
http://codeforces.com/contest/426/problem/B 题意大概就是对称有关,要注意的是,当行数为奇数的时候,答案就是行数本身 #include<iostream ...
- airflow(二)集成EMR使用
1. 准备工作 1.1. 安装并初始化airflow,参考以下文档: https://www.cnblogs.com/zackstang/p/11082322.html 其中还要额外安装的是: sud ...
- 高通mm-camera平台 Camera bring up基本调试思路
原文:https://www.cnblogs.com/thjfk/p/4086001.html 确定硬件 1.首先对照原理图,检查camera module的pin脚连接是否正确. 2.用示波器量Ca ...
- 实时系统Preempt RT与Xenomai之争!谁更主流,谁更实时?
选择争论一直存在 大家知道EtherCAT是实时现场总线技术,当我们开发一款支持EtherCAT总线的控制器时,实时操作系统的选择不仅对于产品本身是最重要的一部分,而且对产品研发的整个过程也影响深远. ...
- 广播变量的使用-----通过ip查询属于哪个省份
1,为什么要使用广播变量? 举一个简单的例子,我们要处理一份log文件,里面有ip地址. 20090121000132095572000|125.213.100.123|show.51.com|/sh ...
- 羊城杯初赛部分misc
羊城杯初赛部分misc Ez_misc i春秋刚考过的CVE,win11截图漏洞CVE-2023-21036(acropalypse) https://github.com/frankthetank- ...
- SQL如何优化和设计索引
SQL优化 对查询进行优化,应尽量避免全表扫描,首先应考虑在 where 及 order by 涉及的列上建立索引: 避免使用 NULL 字段,很难查询优化且占用额外索引空间,可以设置默认值0或'': ...
- mac mysql 设置默认编码格式utf-8
导读 博主百度一番,发现更改mysql默认编码格式,归结以下几个步骤. 详细步骤 切换当前目录 cd / cd private/etc 新建my.cnf文件 在当前目录下:private/etc su ...
- Spring(注解方式)简单入门
环境准备 maven jdk Spring Eclipse 项目创建 pom.xml <project xmlns="http://maven.apache.org/POM/4.0.0 ...
- Linux-Cgroup V2 初体验
本文主要记录 Linux Cgroup V2 版本基本使用操作,包括 cpu.memory 子系统演示. 1. 开启 Cgroup V2 版本检查 通过下面这条命令来查看当前系统使用的 Cgroups ...