$CF241D\ Numbers$
2024-08-30 20:26:46
题目大意:
给你n个数和p,都小于50000要求留下若干个数字,使得剩下的数字异或为0,并且从左到右串联起来可以被p整除,求一种这样的方案。
搜索
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
inline LL read () { LL res = ;int f () ;char ch = getchar ();
while (!isdigit(ch)) { if (ch == '-') f = - ;ch = getchar();}
while (isdigit(ch)) res = (res << ) + (res << ) + (ch ^ ) ,ch = getchar(); return res * f ;
}
template<class T>void write(T x){
if(x>) write(x/);
putchar(+x%);
}
int const maxn=<<;
int n,p,a[maxn],b[maxn],m,check,pos[maxn];
int inline pw(int x){
return x<? :;
}
inline void dfs(int k,int x,int y,int num){
if(x== and y== and num){
puts("Yes"); write(num);putchar('\n');
for(register int i=;i<=num;i++) write(b[i]),putchar(' '); exit();
}
if(k>m) return ;
dfs(k+,x,y,num);
b[num+]=pos[a[k]];
dfs(k+,x^a[k],(y*pw(a[k])+a[k])%p,num+);
}
signed main () {
n=read(),p=read();
for(register int i=;i<=n;i++) {
int x=read();
if(x<maxn) a[++m]=x,pos[x]=i;
}
dfs(,,,); puts("No");
return ;
}
最新文章
- 使用gnucash查看任意时间段内的所有者权益变动表
- Missing separate debuginfos
- nodejs模块——fs模块
- 解决Only a type can be imported. com.mysql.jdbc.Connection resolves to a package的报错问题
- node 事件循环
- div左右布局
- 关于IB_DESIGNABLE / IBInspectable的那些事
- 嵌入式ntp服务器的移植
- linux文件系统拓展属性
- multiSelect 下拉多选插件
- [Poi2010]Monotonicity 2 线段树
- pro asp.net mvc 5笔记
- Java 多线程并发编程之 Synchronized 关键字
- python—函数
- Tesseract-OCR识别
- Fundebug是这样备份数据的
- Codeforces 219C - Color Stripe - [DP]
- (转) CentOS7.4 + MySQL8.0 + Git + Gogs搭建
- 命令卸载ie11
- react config test env with jest and create-react-app 1