JZTXT
  • 首页
  • Ai
  • Java
  • Python
  • Android
  • Mysql
  • JavaScript
  • Html
  • CSS

01trie

发布时间 2023-12-20 11:46:16作者: hubingshan
struct TRIE{
	int tot;
	int ch[N*31][2];
	TRIE(){memset(ch,0,sizeof(ch));tot=1;}
	void insert(int x){
		int p=1;
		for(int i=29;i>=0;i--){
			int c=(x>>i)&1;
			if(!ch[p][c]) ch[p][c]=++tot;
			p=ch[p][c];
		}
	}
	int find(int x){
		int p=1,ans=0;
		for(int i=29;i>=0;i--){
			int c=(x>>i)&1;
			if(ch[p][c]) p=ch[p][c];
			else p=ch[p][c^1],ans|=(1<<i);
		}
		return ans;
	}
	void clear(){
		while(tot) ch[tot][0]=ch[tot][1]=0,tot--;
		tot=1;
	}
}T;
    本栏目推荐文章
  • 2024-01-13 记录react-dnd拖拽组件的用法
  • 01_STM32简介
  • 2024-01-13 react 监听上一页返回
  • 2024-01-13:用go语言,现在有一个打怪类型的游戏,这个游戏是这样的,你有n个技能, 每一个技能会有一个伤害, 同时若怪物小于等于一定的血量,则该技能可能造成双倍伤害, 每一个技能最多只能释放
  • vi / vim编辑器的使用 [补档-2023-07-01]
  • 2024-01-13 antd的tabel组件业务问题之勾选了table中的一项,然后弹出弹窗,接着关闭弹窗,刷新table,但是table选中的一项还是显示被勾选中的状态 ==》你没有改变所选中的数据(selectedRowKeys)
  • 01 Ubuntu 系统的安装
  • 2024-01-13 Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. ==》引用了未使用的方法导致
  • 2024-01-12 训练总结
  • TVBox等智能电视第三方APP可用直播源接口【截止24.01.12】
版权声明:本网站为非赢利性站点,本网站所有内容均来源于互联网相关站点自动搜索采集信息,相关链接已经注明来源。
联系我们