Codeforces 286E

#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的更多相关文章
- CodeForces 286E Ladies' Shop 多项式 FFT
原文链接http://www.cnblogs.com/zhouzhendong/p/8781889.html 题目传送门 - CodeForces 286E 题意 首先,给你$n$个数(并告诉你$m$ ...
- Codeforces 286E - Ladies' Shop(FFT)
Codeforces 题面传送门 & 洛谷题面传送门 好久没刷过 FFT/NTT 的题了,写篇题解罢( 首先考虑什么样的集合 \(T\) 符合条件.我们考察一个 \(x\in S\),根据题意 ...
- codeforces 286E Ladies' Shop
题目大意:n个小于等于m的数,现在你需要在[1,m]中选择若干个数,使得选出的数能组成的所有数正好与n个数相同,给出最少要选多少个数. 题目分析: 结论一:选择的若干个数一定在n个数中. 证明:否则的 ...
- python爬虫学习(5) —— 扒一下codeforces题面
上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...
- 【Codeforces 738D】Sea Battle(贪心)
http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...
- 【Codeforces 738C】Road to Cinema
http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...
- 【Codeforces 738A】Interview with Oleg
http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...
- CodeForces - 662A Gambling Nim
http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...
- CodeForces - 274B Zero Tree
http://codeforces.com/problemset/problem/274/B 题目大意: 给定你一颗树,每个点上有权值. 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连 ...
随机推荐
- ecshop物料库存管理
1.创建物流库存表.sql语句: CREATE TABLE IF NOT EXISTS `emws_materials` (`id` mediumint(8) unsigned NOT NULL au ...
- 基于DateTime Picker修改成类似旅游网站出发日期选择的功能
原版说明文档:http://www.bootcss.com/p/bootstrap-datetimepicker/ 修改后可支持多日期选择和控制可选日期,这样就能在后台设置哪些日期可选,前台展示时可以 ...
- PHP每日签到及连续签到奖励实现示例
数据库字段 num 记录已经连续签到次数 times 记录签到的日期 格式年月日 如 20160101 PHP代码如下 <?php //获取今天的日期 $today = date('Ymd'); ...
- supervisor python开发的进程管理工具
Supervisor (http://supervisord.org) 是一个用 Python 写的进程管理工具,可以很方便的用来启动.重启.关闭进程(不仅仅是 Python 进程).除了对单个进程的 ...
- KeyEvent
http://blog.csdn.net/elfylin/article/details/8008763 一. 接口KeyEvent.Callback和View.OnKeyListener 二. 流程 ...
- NFC介绍
简介 本文介绍Nokia设备所支持的近场通信技术(NFC)及相关的功能.旨在为使用 Qt/Symbian/Java™ API为Nokia手机开发应用的开发者 刚开始接触NFC开发时提供有用的信息. 什 ...
- Google map v3 using simple tool file google.map.util.js v 1.2
更新添加日志:在1.1的基础上添加marker的文字显示.测距工具. /** * GOOGLE地图开发使用工具 * @author BOONYACHENGDU@GMAIL.COM * @date 20 ...
- spring mvc <mvc:annotation-driven>配置使用出现故障
我在使用converter进行全局的日期类型转换. 1.写converer public class CustomDateConverter implements Converter<Strin ...
- cocos2d_android 瞬间动作
该文章所写的瞬间动作主要有CCFlipX,CCFlipY,CCHide,CCShow 当中CCFlipX是以Y轴为中心旋转,CCFlipY是以X轴为中心旋转,CCHide将精灵对象隐藏,CCShow将 ...
- android同时使用多个library时的问题
剧情是这样,我的app要使用四个library,如:LibraryA,LibraryB.这两个库又都需要support.v4.jar. 由于加载的时间不同,所以四个support.v4.jar不同,出 ...