当前位置: 首页 > 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.dtcms.com/a/310625.html

相关文章:

  • 1.2.6 装配式混凝土建筑设计构造要求
  • LOVON——面向足式Open-Vocabulary的物体导航:LLM做任务分解、YOLO11做目标检测,最后L2MM将指令和视觉映射为动作(且解决动态模糊)
  • RAGFLOW~knowledge graph
  • JavaScript 中的对象继承:从浅入深
  • 2025牛客多校第六场D题解
  • Object对象中的常用方法
  • 当10米精度遇上64维AI大脑——Google全球卫星嵌入数据集(Satellite Embedding V1)全解析
  • 【华为机试】34. 在排序数组中查找元素的第一个和最后一个位置
  • 移动端 WebView 内存泄漏与性能退化问题如何排查 实战调试方法汇总
  • 文章发布Typecho网站技巧
  • Squid服务配置代理
  • SystemVerilog的系统函数和任务
  • Python 项目路径配置完全指南
  • C语言-字符串(定义)、字符串函数(strlen、strcat、strcpy、strcmp、strlwr、strupr)
  • 航天器VHF/UHF/L频段弱电磁信号兼容性设计
  • 【3】交互式图表制作及应用方法
  • Spring Cloud 和服务拆分:微服务落地的第一步
  • Java抽象类与接口深度解析:核心区别与应用场景全指南
  • C++ - 仿 RabbitMQ 实现消息队列--服务端核心模块实现(五)
  • 流式输出:概念、技巧与常见问题
  • c++详解(宏与内联函数,nullptr)
  • 每日面试题18:基本数据类型和引用数据类型的区别
  • 唐克的新游戏
  • 100道题通过CISSP,还剩70分钟
  • 体育数据API接入方式与数据类型详解
  • 连载【流程规划进阶 16/16】完结——35页16.流程的现状分析 【附全文阅读】
  • 达梦数据库权限体系详解:系统权限与对象权限
  • 大模型微调与部署课程笔记
  • FreeRTOS硬件中断发生时的现场
  • Spring AI 与 LangChain4j 对比及入门案例解析