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

2025多校冲刺CSP模拟赛7

2025多校冲刺CSP模拟赛7

不是你怎么还有加赛?ys

A. gcd&xor (gcdxor)

转化为外层枚举 \(\gcd\),内层枚举 \(i,j\),打表即可。可以发现规律,是调和级数做法,时间复杂度大约 \(O(1.5 \times 10^8)\)

Code:

#include<bits/stdc++.h>
#define int long longusing namespace std;const int Size=(1<<20)+1;
char buf[Size],*p1=buf,*p2=buf;
char buffer[Size];
int op1=-1;
const int op2=Size-1;
#define getchar()                                                              \
(tt == ss && (tt=(ss=In)+fread(In, 1, 1 << 20, stdin), ss == tt)     \? EOF                                                                 \: *ss++)
char In[1<<20],*ss=In,*tt=In;
inline int read()
{int x=0,c=getchar(),f=0;for(;c>'9'||c<'0';f=c=='-',c=getchar());for(;c>='0'&&c<='9';c=getchar())x=(x<<1)+(x<<3)+(c^48);return f?-x:x;
}
inline void write(int x)
{if(x<0) x=-x,putchar('-');if(x>9)  write(x/10);putchar(x%10+'0');
}// #ifndef ONLINE_JUDGE
// #define ONLINE_JUDGE
// #endif// int logn[1<<20];
// vector<pair<int,int> > v[20][1<<16];signed main()
{// #ifndef ONLINE_JUDGEfreopen("gcdxor.in","r",stdin);freopen("gcdxor.out","w",stdout);int n;int ans=0;cin>>n;for(int i=1;i<=n;i++)for(int j=i;j<=n-i;j+=i)ans+=(j^(j+i))==i;cout<<ans;// for(int i=2;i<(1<<20);i++) logn[i]=logn[i>>1]+1;// for(int k=1;;k<<=1)// {// 	int L=1<<logn[k],R=min(n,(1ll<<(logn[k]+1))-1);// 	if(L>n) break;// 	cerr<<L<<" "<<R<<"\n";// 	for(int i=L;i<=R;i++)// 	for(int j=i+1;j<=R;j++)// 	{// 		if(__gcd(i,j)==(i^j))// 		{// 			v[logn[k]][i^j].push_back(make_pair(i,j));// 			// cout<<i<<" "<<j<<" "<<(i^j)<<"\n";// 			ans++;// 		}// 	}// 	// cerr<<"\n------------------\n\n";// }// for(int i=1;i<=n;i++)// {// 	bool f=0;// 	for(int k=1;k<=logn[n];k++)// 	{// 		if(v[k][i].empty()) continue;// 		f=1;// 		cout<<"\nxor="<<i<<"\nk="<<k<<"\n";// 		for(auto nw:v[k][i]) cout<<nw.first<<","<<nw.second<<"\n";// 	}// 	if(f) cout<<"\n-----------------------------------------\n";// }// cout<<ans;// #endif//mt19937_64 myrand(time(0));return 0;
}

B. 异或树 (xortree)

暴力写假两次,std 写假一次。

发现规律。加一次点后,只有加操作之前的那些叶子节点的子树 xor 值会更改。非叶子节点的子树 xor 值均固定。

又发现值域很小。所以直接暴力 dp 更改即可。复杂度小常数 \(O(nV)\),可以通过。

注意:有人 (HS_fu3) 使用 unordered_map 被卡常了。

Code:

#include<bits/stdc++.h>
#define int long longusing namespace std;const int Size=(1<<20)+1;
char buf[Size],*p1=buf,*p2=buf;
char buffer[Size];
int op1=-1;
const int op2=Size-1;
#define getchar()                                                              \
(tt == ss && (tt=(ss=In)+fread(In, 1, 1 << 20, stdin), ss == tt)     \? EOF                                                                 \: *ss++)
char In[1<<20],*ss=In,*tt=In;
inline int read()
{int x=0,c=getchar(),f=0;for(;c>'9'||c<'0';f=c=='-',c=getchar());for(;c>='0'&&c<='9';c=getchar())x=(x<<1)+(x<<3)+(c^48);return f?-x:x;
}
inline void write(int x)
{if(x<0) x=-x,putchar('-');if(x>9)  write(x/10);putchar(x%10+'0');
}// #ifndef ONLINE_JUDGE
// #define ONLINE_JUDGE
// #endifint k0,q;
struct Node{int op,x;
}a[1<<20];vector<int> E[1<<20];
int val[1<<20];
int cnt[8193];
int sum[1<<22];
int tot=1;void dfs(int p,int x)
{// cerr<<p<<" "<<x<<" "<<E[p].size()<<"\n";// exit(0);if(!E[p].size()){E[p].push_back(++tot);E[p].push_back(++tot);val[tot-1]=val[p];val[tot]=val[p]^x;return;}dfs(E[p][0],x);dfs(E[p][1],x);
}void find(int p)
{sum[p]=val[p];for(int to:E[p]){find(to);sum[p]^=sum[to];}cnt[sum[p]]++;
}signed main()
{//xortree// #ifndef ONLINE_JUDGEfreopen("xortree.in","r",stdin);freopen("baoli.out","w",stdout);k0=read();q=read();val[1]=k0;cnt[k0]=1;for(int i=1;i<=q;i++){int op=read(),x=read();a[i]={op,x};if(op==1){memset(cnt,0,sizeof(cnt));memset(sum,0,sizeof(sum));dfs(1,x);find(1);}else{// dd(1);cout<<cnt[x]<<"\n";}}// #endif//mt19937_64 myrand(time(0));return 0;
}

C. 符文石 (stone)

困难题。

Code:


D. 彩色括号 (witch)

场上拿了 15 pts 部分分跑路了。

Code:


http://www.hskmm.com/?act=detail&tid=36608

相关文章:

  • 视频汇聚平台EasyCVR级联播放偶发失败排查:TCP主动模式下的3秒超时响应差
  • redis 5.0单机部署
  • 企业微信ipad协议,标准化接口服务解决方案
  • Python-配置PyCharm使用正确的Python解释器
  • pytorch第66页
  • Navicat Premium 17 官方版下载安装教程|支持MySQL、PostgreSQL、MongoDB等数据库
  • 从埋点到用户行为分析:ClkLog 如何帮助企业读懂用户
  • 函数的高级
  • C#实现OPC客户端
  • Gitee:数字化转型浪潮中的项目管理利器
  • 有什么指标可以判断手机是否降频
  • 实用指南:Linux内核kallsyms符号压缩与解压机制
  • 5G企业应用的七大场景与商业机遇
  • 2025 水泥墩源头厂家最新推荐排行榜:光伏 / 围挡 / 交通 / 防撞水泥墩多品类优选,实力品牌权威榜单
  • 高效数据结构 - 循环队列
  • 2025 年国内活塞杆厂家最新推荐排行榜:聚焦精密 / 不锈钢 / 油缸 / 气缸 / 45# 镀铬类产品,助力企业精准挑选可靠合作方
  • Day16
  • 数据类型,二元运算符,自动类型提升规则,关系运算,取余模运算
  • 股票技术面分析平台QuantMatrix深度解析 - 实践
  • 迷宫问题
  • WPF使用MediaCapture开发相机应用(四、相机录视频)
  • 链队
  • Gitee本土化战略深度解析:中国开发者生态的合规与效率革命
  • 2025年10月上海装修公司口碑榜:十强对比评测
  • 02-GPIO-铁头山羊STM32标准库新版笔记
  • 【多校支持、EI检索】第六届大数据与社会科学国际学术会议(ICBDSS 2025)
  • IDC iPaaS市场报告解读:独立厂商与云巨头的“双轨竞速”
  • 2025年10月仓储管理系统推荐:鸿链云仓领衔五大方案对比评测榜
  • 2025年10月电动叉车销售公司排行榜:五家主流服务商对比评测
  • 2025年口罩机厂家权威推荐榜:全自动口罩机器,全自动KN95口罩机源头企业综合评测与采购指南