当前位置: 首页 > news >正文

代码源挑战赛 Round 41

代码源挑战赛 Round 41

2025.12.12

A. [R41A]出题组3

link
image
image

\(Solution:\)

用取模模拟即可。

code
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define ull unsigned long long
#define inf 1e12
#define eps 1e-9
#define endl "\n"
#define il inline
#define ls 2*k
#define rs 2*k+1
using namespace std;
const int N=2e5+5,M=3e6+5;
inline int read(){int x=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();return x*f;
}
int n,x,y,k; 
signed main(){n=read(),x=read(),y=read(),k=read();for(int i=x+1;i<=k;i++) y=(y+1)%n;cout<<(!y ? n : y);return 0;
}

B. [R41B]购物

link
image
image

\(Solution:\)

贪心。将 \(a_i\) 升序排序,先选较小的 $ a_i $ 。

code
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define ull unsigned long long
#define inf 1e12
#define eps 1e-9
#define endl "\n"
#define il inline
#define ls 2*k
#define rs 2*k+1
using namespace std;
const int N=2e5+5,M=3e6+5;
inline int read(){int x=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();return x*f;
}
int n,a[N],V,ans;
signed main(){n=read(),V=read();for(int i=1;i<=n;i++) a[i]=read();sort(a+1,a+n+1);for(int i=1;i<=n;i++){V-=a[i];if(V>=0) ans=max(ans,i);else break;}cout<<ans;return 0;
}

C. [R41C]文本编辑器

link
image
image

\(Solution:\)

维护一个栈来模拟打字过程即可。

code
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define ull unsigned long long
#define inf 1e12
#define eps 1e-9
#define endl "\n"
#define il inline
#define ls 2*k
#define rs 2*k+1
using namespace std;
const int N=5e5+5,M=3e6+5;
inline int read(){int x=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();return x*f;
}
int n,flag=1,top;
char res[N],s[N];
signed main(){ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);cin>>n;for(int i=1;i<=n;i++) cin>>s[i];for(int i=1;i<=n;i++){if(s[i]>='a' && s[i]<='z'){if(flag==1) res[++top]=s[i];else res[++top]=(s[i]-32);}else if(s[i]=='@') flag^=1;else{if(top) top--;}}for(int i=1;i<=top;i++) cout<<res[i];return 0;
}
http://www.jsqmd.com/news/79199/

相关文章:

  • 详细介绍:NumPy / pandas 类型选型、内存占用与性能优化
  • 告别选择困难!2025年远程控制软件场景化终极横评
  • 一种可落地的任务令牌锁机制:设计原理、实战经验与容器化演进
  • [JSK]二叉苹果树
  • 【题解】Luogu P8137 [ICPC2020 WF] ’S No Problem
  • Day 36 官方文档的阅读
  • 青少年编程学习:考级与竞赛如何平衡
  • 2025 Autel MaxiVCI V150 Wireless Dongle: CAN FD/DOIP for Autel 900 Series Scanners
  • 【UI Qt】入门笔记
  • WSL安装方法
  • Ubuntu环境中LLaMA Factory 的部署与配置—构建大语言模型微调平台 - 实践
  • 2025贵阳公墓/公益公墓top5推荐!贵阳优质生态陵园榜单发布,合规保障与人文关怀兼具的安息之所推荐 - 全局中转站
  • 【题解】Luogu P2354 [NOI2014] 随机数生成器
  • 基于Django的农场管理系统
  • rsync交叉编译步骤
  • 下载UCI数据集《Secondary Mushroom》
  • 【题解】P11453 [USACO24DEC] Deforestation S
  • 03 以上版本 Excel 文件解压替换图片
  • 【题解】Luogu P13977 数列分块入门 2
  • AI核心知识50——大语言模型之Scaling Laws(简洁且通俗易懂版)
  • MySQL 深分页查询优化实践与经验总结
  • P2014 [CTSC1997] 选课
  • 彻底讲清 MySQL InnoDB 锁机制:从 Record 到 Next-Key 的全景理解
  • 超越宣传:基于数据与案例的软件人才外包服务商价值评估指南
  • MCU的启动流程你了解么?
  • 电机多目标优化与灵敏度分析:探索电机性能提升之道
  • I2C通信最全面的讲解:从协议到硬件设计
  • 打造下一个爆款!专业短剧APP全栈开发解决方案,解锁万亿级市场红利
  • 毕业论文选题AI推荐:9大工具+热门方向合集
  • 【题解】Luogu P10752 [COI 2024] Sirologija