problem

题目大意:

给你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 ;
}

最新文章

  1. 使用gnucash查看任意时间段内的所有者权益变动表
  2. Missing separate debuginfos
  3. nodejs模块——fs模块
  4. 解决Only a type can be imported. com.mysql.jdbc.Connection resolves to a package的报错问题
  5. node 事件循环
  6. div左右布局
  7. 关于IB_DESIGNABLE / IBInspectable的那些事
  8. 嵌入式ntp服务器的移植
  9. linux文件系统拓展属性
  10. multiSelect 下拉多选插件
  11. [Poi2010]Monotonicity 2 线段树
  12. pro asp.net mvc 5笔记
  13. Java 多线程并发编程之 Synchronized 关键字
  14. python—函数
  15. Tesseract-OCR识别
  16. Fundebug是这样备份数据的
  17. Codeforces 219C - Color Stripe - [DP]
  18. (转) CentOS7.4 + MySQL8.0 + Git + Gogs搭建
  19. 命令卸载ie11
  20. react config test env with jest and create-react-app 1

热门文章

  1. Linux读取网卡流量脚本
  2. [luoguP1077] 摆花(DP)
  3. Just a Hook-HDU1698(线段树求区间)
  4. POJ1328 Radar Installation 解题报告
  5. Nginx+Tomcat+Memcached负载均衡和session共享
  6. jquery校验框架
  7. SaltStack学习系列之自定义grains
  8. mongodb的备忘录
  9. leetcode笔记:Search in Rotated Sorted Array
  10. bootstrap 时间控件