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

上海月赛kk

1.十六进制

#include<bits/stdc++.h>
using namespace std;int n;int main(){cin>>n;stack<int>re;if(n<16)cout<<0;while(n){re.push(n%16);n/=16;}while(!re.empty()){int x=re.top();re.pop();if(x<10)cout<<x;else cout<<char('A'+x-10);}return 0;
}

2.游戏

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+10;int t,n;int main(){ios::sync_with_stdio(false);cin>>t;while(t--){vector<pair<ll,ll>>p;cin>>n;for(int i=0;i<n;++i){ll a,b;cin>>a>>b;p.push_back({a,b});			}sort(p.begin(),p.end());ll ans=p[0].first;for(int i=1;i<n;++i){ll a=p[i-1].second-p[i].second;ll b=p[i].first-p[i-1].first;ans+=min(a,b);}ans+=p[n-1].second;cout<<ans<<'\n';}return 0;
}

4.染色

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=4e5+10;int t;
int n,a;
ll sum;int main(){ios::sync_with_stdio(false);cin>>t;while(t--){sum=0;cin>>n;for(int i=0;i<n;++i){cin>>a;sum+=a;}if(n<2||sum%2!=0){cout<<0<<'\n';continue;}else cout<<n*(n-1)/2<<'\n';}return 0;
}

5。不要回文

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=3e5+10;int q,n;
string s;int main(){cin>>q;while(q--){cin>>n>>s;int c[30]{0};for(auto i:s)c[i-'a']++;vector<int>who;for(int i=0;i<26;++i){if(c[i])who.push_back(c[i]);}sort(who.begin(),who.end());int l=0,f=1;for(auto i:who){//cout<<i<<" ";if(i>max(l/2+1,0)){f=0;break;}l+=i;}if(f)cout<<"Yes\n";else cout<<"No\n";		}return 0;
}

6.面包

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=3e5+10;int n;
ll d,p,r,sum=0;
vector<array<ll,3>>who;int main(){cin>>n;for(int i=1;i<=n;++i){cin>>d>>p>>r;who.push_back({d,i,1});who.push_back({p,i,2});who.push_back({r,i,3});}sort(who.begin(),who.end());int c[N]{0},t=0,q[4]{0};for(int i=who.size()-1;i>=0;--i){auto x=who[i];if(t==n){sum+=x[0];}else if(c[x[1]]==0){if(3-q[1]-q[2]-q[3]>=n-t&&q[x[2]]){sum+=x[0];}else{c[x[1]]=1;t++;q[x[2]]=1;}}else{sum+=x[0];}}cout<<sum;return 0;
}

http://www.lryc.cn/news/607682.html

相关文章:

  • 电力系统与变压器实验知识全总结 | 有功无功、同步发电机、短路空载实验、电压调整率、效率条件全讲透!
  • 学习嵌入式第十七天
  • 基于coze studio开源框架二次定制开发教程
  • 幂等性校验(订单重复提交问题)
  • IOMMU Client设备DMA配置过程分析(九)
  • STM32 使用 RTC 实现实时时钟功能
  • C语言:20250801学习(构造类型)
  • 机器学习:开启智能时代的钥匙
  • MySQL 高并发下如何保证事务提交的绝对顺序?
  • 学习笔记:原子操作与锁以及share_ptr的c++实现
  • synchronized 深度剖析:从语法到锁升级的完整演进
  • 什么是Sedex审核?Sedex审核的主要内容,Sedex审核的流程
  • 通用障碍物调研
  • 【C++进阶】一文吃透静态绑定、动态绑定与多态底层机制(含虚函数、vptr、thunk、RTTI)
  • 测试分类:详解各类测试方式与方法
  • 使用gcc代替v语言的tcc编译器提高编译后二进制文件执行速度
  • Trust Management System (TMS)
  • MySQL锁的分类 MVCC和S/X锁的互补关系
  • Linux编程: 10、线程池与初识网络编程
  • GESP2025年6月认证C++八级( 第三部分编程题(1)树上旅行)
  • 链表【各种题型+对应LeetCode习题练习】
  • 《C++》STL--list容器详解
  • UnionApplication
  • 江协科技STM32 12-2 BKP备份寄存器RTC实时时钟
  • 【Shell脚本自动化编写——报警邮件,检查磁盘,web服务检测】
  • Windows安装虚拟机遇到内容解码失败
  • python-异常(笔记)
  • Java学习-运算符
  • Java:JWT 从原理到高频面试题解析
  • 【Linux】重生之从零开始学习运维之Mysql