题意:打高尔夫 给你n个距离表示你一次可以把球打远的距离

   然后对于m个询问 问能否在两杆内把球打进洞

题解:平方一下就好 注意一下x0的系数为1表示打一杆

   才发现数组应该开MAXN * 4 之前写的题数据有点不严谨了

#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <math.h>
using namespace std;
const double PI = acos(-1.0);
const double eps = 1e-; struct Complex
{
double x, y;
Complex(double _x = 0.0, double _y = 0.0)
{
x = _x;
y = _y;
}
Complex operator + (const Complex &b) const
{
return Complex(x + b.x, y + b.y);
}
Complex operator - (const Complex &b) const
{
return Complex(x - b.x, y - b.y);
}
Complex operator * (const Complex &b) const
{
return Complex(x * b.x - y * b.y, x * b.y + y * b.x);
}
}; void change(Complex y[], int len)
{
int i, j, k;
for(i = , j = len / ; i < len - ;i++)
{
if(i < j) swap(y[i], y[j]);
k = len / ;
while(j >= k)
{
j -= k;
k /= ;
}
if(j < k) j += k;
}
} void fft(Complex y[], int len, int on)
{
change(y, len);
for(int h = ; h <= len; h <<= )
{
Complex wn(cos(-on * * PI / h), sin(-on * * PI / h));
for(int j = ; j < len; j += h)
{
Complex w(, );
for(int k = j; k < j + h / ; k++)
{
Complex u = y[k];
Complex t = w * y[k + h / ];
y[k] = u + t;
y[k + h / ] = u - t;
w = w * wn;
}
}
}
if(on == -)
for(int i = ; i < len; i++)
y[i].x /= len;
} Complex x1[]; int main()
{
int n, m;
while(~scanf("%d", &n))
{
int zd = ;
for(int i = ; i <= ; i++) x1[i] = Complex(, );
for(int i = ; i <= n; i++)
{
int x; scanf("%d", &x);
zd = max(zd, x);
x1[x] = Complex(, );
}
x1[] = Complex(, ); int len = ;
while(len < zd + ) len <<= ;
len <<= ;
for(int i = zd + ; i < len; i++) x1[i] = Complex(, ); fft(x1, len, );
for(int i = ; i < len; i++) x1[i] = x1[i] * x1[i];
fft(x1, len, -); scanf("%d", &m);
int ans = ;
for(int i = ; i <= m; i++)
{
int xx; scanf("%d", &xx);
if(fabs(x1[xx].x) > eps) ans++;
}
printf("%d\n", ans);
}
return ;
}

UVALIVE6886 Golf Bot (FFT)的更多相关文章

  1. UVALive 6886 Golf Bot FFT

    Golf Bot 题目连接: http://acm.hust.edu.cn/vjudge/problem/visitOriginUrl.action?id=129724 Description Do ...

  2. Gym 100783C Golf Bot FFT

    大致题意: 给你N个整数和M个整数,问这M个数中,有几个数可以表达成那N个整数中一个或者两个整数的和. 分析: 算是半个裸的FFT.FFT可以用来在nlongn时间内求高精度乘法,我们先模拟一下乘法. ...

  3. LA6886 Golf Bot(FFT)

    题目 Source https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page= ...

  4. UVALive - 6886 Golf Bot 多项式乘法(FFT)

    题目链接: http://acm.hust.edu.cn/vjudge/problem/129724 Golf Bot Time Limit: 15000MS 题意 给你n个数,m个查询,对于每个查询 ...

  5. HNU11376:Golf Bot

    Problem description Input The first line has one integer: N, the number of different distances the G ...

  6. Gym100783C Golf Bot(FFT)

    https://vjudge.net/problem/Gym-100783C 题意: 给出n个数,然后有m次查询,每次输入一个数x,问x能否由n个数中2个及2个以下的数相加组成. 思路:题意很简单,但 ...

  7. [Swerc2014 C]Golf Bot

    题意:给你N个数字,每次利用这N个数字中最多两个数字进行加法运算,来得到目标中的M个数字. Solution: 我们先来看看多项式乘法:\(A(x)=\sum_{i=0}^{n-1}a_ix^i\), ...

  8. FFT题集

    FFT学习参考这两篇博客,很详细,结合这看,互补. 博客一 博客二 很大一部分题目需要构造多项式相乘来进行计数问题. 1. HDU 1402 A * B Problem Plus 把A和B分别当作多项 ...

  9. 并行计算提升32K*32K点(32位浮点数) FFT计算速度(4核八线程E3处理器)

    对32K*32K的随机数矩阵进行FFT变换,数的格式是32位浮点数.将产生的数据存放在堆上,对每一行数据进行N=32K的FFT,记录32K次fft的时间. 比较串行for循环和并行for循环的运行时间 ...

随机推荐

  1. Linux地址ping不通情况怎么办?

    查看原文:http://www.ibloger.net/article/325.html Linux地址ping不通情况怎么办? 问题:今天写了一个微信支付的项目.有一个class中使用了httpPo ...

  2. NDK开发,没有你想象的那么难

    NDK:Native Development Kit原生开发工具 NDK能干什么:NDK使得在android中,java能够调用C函数库. 为什么要用NDK:我们都知道.java是半解释型语言,非常e ...

  3. VELT-0.1.6开发:载入根文件系统

    快乐虾 http://blog.csdn.net/lights_joy/(QQ群:Visual EmbedLinux Tools 375515651) 欢迎转载,但请保留作者信息 VELT的全称是Vi ...

  4. java 开发webservice

    这几天用java开发一个webservice,搞死了.java果然很难侍候! 传说java搞webservice,有好几种途径(为什么不是一种?要搞这么多种,让人一听,头都大了.当然啦,生物多样性总是 ...

  5. struts2基础代码实现

    结构图: load.jsp <%@ page language="java" import="java.util.*" pageEncoding=&quo ...

  6. Proxy authentication confirmation prompt keeps popping up although the user/password is saved 火狐浏览器一直提示输入代理的账号和密码

    https://support.mozilla.org/zh-CN/questions/943488 signon.autologin.proxy;true network.proxy.share_p ...

  7. 分享一个全开源的ASP.NET快速开发平台,能快速开发OA CRM ERP 等系统

    bingo炸了 2017/3/30 16:28:14 阅读(870) 评论(0) 公司业务量比较大,接了很多项目,为了缩短开发周期老板让我牵头搭建了一个快速开发平台. 我们主要的业务是做OA.CRM. ...

  8. 2018.09.08 DL24 Day1 总结

    补一下之前的总结…… T1.restaurant 这道题还是很简单的嘛,子恒dalao非常良心.我们把招牌菜和所需要的菜品绑定在一起就成了完全背包,然后直接跑一遍完全背包即可. #include< ...

  9. 杂项-Java:JSP

    ylbtech-杂项-Java:JSP 1.返回顶部 1. JSP全名为Java Server Pages,中文名叫java服务器页面,其根本是一个简化的Servlet设计,它是由Sun Micros ...

  10. ECS服务器配置密钥登录及常用日志

    一.介绍 1.SSH(22端口)是Secure Shell Protocol的简写,由IETF网络工作小组(Network Working Group)制定:在进行数据传输之前,SSH先对联机数据包通 ...