#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <set>
#include <map>
using namespace std; const int maxn=int(1e6)+;
const double eps=0.5;
const double PI=acos(-); struct Complex
{
double real, imag; Complex(double _x=, double _y=):real(_x), imag(_y) {} Complex operator + (Complex b)
{
return Complex(real+b.real, imag+b.imag);
} Complex operator - (Complex b)
{
return Complex(real-b.real, imag-b.imag);
} Complex operator * (Complex b)
{
return Complex(real*b.real-imag*b.imag, real*b.imag+b.real*imag);
}
}; int n, m;
int lg, wide;
bool vis[maxn];
int ans[maxn], rev[maxn*];
Complex a[maxn*]; void init()
{
scanf("%d%d", &n, &m);
for (int i=; i<=n; ++i)
{
int num;
scanf("%d", &num);
vis[num]=true;
a[num].real=;
}
}
void init_order()
{
for (int i=; i<wide; ++i)
for (int j=; j<lg; ++j)
rev[i]=(rev[i]<<) | (i>>j & );
}
void FFT(int type)
{
for (int i=; i<wide; ++i)
if (rev[i]>i) swap(a[i], a[rev[i]]); for (int i=; i<=wide; i<<=)
for (int j=; j<wide; j+=i)
{
Complex w(cos(PI*/i), sin(PI*/i*(-type)));
Complex wn(, );
for (int k=; k<i>>; ++k, wn=wn*w)
{
Complex tmp=a[j+k];
a[j+k]=tmp+wn*a[j+k+(i>>)];
a[j+k+(i>>)]=tmp-wn*a[j+k+(i>>)];
}
}
}
void solve()
{
lg=;
while (<<lg<m*) ++lg;
wide=<<lg;
init_order();
FFT();
for (int i=; i<wide; ++i) a[i]=a[i]*a[i];
FFT(-);
for (int i=; i<wide; ++i) a[i].real/=wide;
/*
for (int i=0; i<wide; ++i)
printf("%d ", int(a[i].real+0.5));
*/
bool flag=true;
for (int i=; i<=m; ++i)
if (a[i].real>eps && !vis[i])
{
flag=false;
break;
}
if (!flag) printf("NO\n");
else
{
printf("YES\n");
for (int i=; i<=m; ++i)
if (vis[i] && a[i].real<eps)
ans[++ans[]]=i;
printf("%d\n", ans[]);
for (int i=; i<=ans[]; ++i)
printf("%d ", ans[i]);
}
}
int main()
{
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
init();
solve();
return ;
}

Codeforces 286E的更多相关文章

  1. CodeForces 286E Ladies' Shop 多项式 FFT

    原文链接http://www.cnblogs.com/zhouzhendong/p/8781889.html 题目传送门 - CodeForces 286E 题意 首先,给你$n$个数(并告诉你$m$ ...

  2. Codeforces 286E - Ladies' Shop(FFT)

    Codeforces 题面传送门 & 洛谷题面传送门 好久没刷过 FFT/NTT 的题了,写篇题解罢( 首先考虑什么样的集合 \(T\) 符合条件.我们考察一个 \(x\in S\),根据题意 ...

  3. codeforces 286E Ladies' Shop

    题目大意:n个小于等于m的数,现在你需要在[1,m]中选择若干个数,使得选出的数能组成的所有数正好与n个数相同,给出最少要选多少个数. 题目分析: 结论一:选择的若干个数一定在n个数中. 证明:否则的 ...

  4. python爬虫学习(5) —— 扒一下codeforces题面

    上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...

  5. 【Codeforces 738D】Sea Battle(贪心)

    http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...

  6. 【Codeforces 738C】Road to Cinema

    http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...

  7. 【Codeforces 738A】Interview with Oleg

    http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...

  8. CodeForces - 662A Gambling Nim

    http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...

  9. CodeForces - 274B Zero Tree

    http://codeforces.com/problemset/problem/274/B 题目大意: 给定你一颗树,每个点上有权值. 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连 ...

随机推荐

  1. How Many Tables(并查集)

    How Many Tables Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)T ...

  2. TensorFlow深度学习笔记 循环神经网络实践

    转载请注明作者:梦里风林 Github工程地址:https://github.com/ahangchen/GDLnotes 欢迎star,有问题可以到Issue区讨论 官方教程地址 视频/字幕下载 加 ...

  3. Linux上配置Nginx+PHP5(FastCGI)

    原为地址:http://www.laruence.com/2009/07/28/1030.html Nginx是俄罗斯人编写的十分轻量级的HTTP服务器,以事件驱动的方式编写,所以有非常好的性能,同时 ...

  4. Android下EditText中的字体不统一问题

    Android下EditText中的字体不统一问题 好久没写,今天心情好略记下解决的某bug 在一个登录界面有帐号和密码两个EditText,但是却发现两个EditText的hint的英文字体不同,看 ...

  5. mysql 开启事务

    START TRANSACTION, COMMIT, and ROLLBACK Syntax 开始事务,提交和回滚语法 那些语句提供了控制事务的使用: 1.START TRANSACTION 或者BE ...

  6. Java报表开发组件DynamicReports

    DynamicReports 是一个基于 JasperReports 进行扩展的 Java 报表库,可用它来快速创建报表而无需可视化报表设计工具. From :  http://www.oschina ...

  7. 网页前台的iframe控制内部刷新子页

    <body> <!--Header--> <uc1:top runat="server" ID="top" /> <! ...

  8. (转)轻量级数据库 SQLite

    SQLite Expert – Personal Edition SQLite Expert 提供两个版本,分别是个人版和专业版.其中个人版是免费的,提供了大多数基本的管理功能. SQLite Exp ...

  9. SharePoint 2013 代码实现自定义的站点模版创建Site Collection

    先需要将自定义的站点模版从网站集转移到Farm中. 找一个自己已经完成配置及设计的网站,在网站设置里面选择另存为模版.要注意的是不是所有的站点类型都有另存为模版的功能. 存完之后可在解决方案库的界面里 ...

  10. JavaScript 中 关于 this 的学习笔记

    今天上午主要学习了js中的 this ,因为之前学习面向对象时,this这个东西出现的还是很频繁的,理解的很不透彻,感觉老被JAVA的思想带进坑里,所以对它特别关注. 首先贴一个大神的一篇博客,我是通 ...