XTUOJ1250 Super Fast Fourier Transform 暴力
分析:因为加起来不超过1e6,所以最多有1000+个不同的数
做法:离散化搞就好了
#include <cstdio>
#include <iostream>
#include <ctime>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <algorithm>
#include <cstring>
using namespace std;
typedef long long LL;
const int N=1e5+;
const int INF=0x3f3f3f3f;
const int mod=1e9+;
int a[N],b[N],c[N],k1[N],k2[N];
int main()
{
int n,m;
while(~scanf("%d%d",&n,&m)){
for(int i=;i<=n;++i){
scanf("%d",&a[i]);
c[i]=a[i];
}
sort(a+,a++n);
int cnt1=unique(a+,a++n)-a-;
memset(k1,,sizeof(k1));
for(int i=;i<=n;++i){
++k1[lower_bound(a+,a++cnt1,c[i])-a];
}
for(int i=;i<=m;++i){
scanf("%d",&b[i]);
c[i]=b[i];
}
sort(b+,b++m);
int cnt2=unique(b+,b++m)-b-;
memset(k2,,sizeof(k2));
for(int i=;i<=m;++i){
++k2[lower_bound(b+,b++cnt2,c[i])-b];
}
LL ret=;
for(int i=;i<=cnt1;++i){
for(int j=;j<=cnt2;++j){
LL tmp=sqrt(abs(a[i]-b[j]));
ret+=1ll*k1[i]*k2[j]*tmp;
}
}
printf("%I64d\n",ret);
}
return ;
}
XTUOJ1250 Super Fast Fourier Transform 暴力的更多相关文章
- 1250 Super Fast Fourier Transform(湘潭邀请赛 暴力 思维)
		湘潭邀请赛的一题,名字叫"超级FFT"最终暴力就行,还是思维不够灵活,要吸取教训. 由于每组数据总量只有1e5这个级别,和不超过1e6,故先预处理再暴力即可. #include&l ... 
- XTU 1250 Super Fast Fourier Transform
		$2016$长城信息杯中国大学生程序设计竞赛中南邀请赛$H$题 排序,二分. 对$a$数组,$b$数组从小到大进行排序. 统计每一个$a[i]$作为较大值的时候与$b[i]$对答案的贡献.反过来再统计 ... 
- 数字图像处理实验(5):PROJECT 04-01 [Multiple Uses],Two-Dimensional Fast Fourier Transform                                                                                                         标签:               图像处理MATLAB数字图像处理
		实验要求: Objective: To further understand the well-known algorithm Fast Fourier Transform (FFT) and ver ... 
- 「学习笔记」Fast Fourier Transform
		前言 快速傅里叶变换(\(\text{Fast Fourier Transform,FFT}\) )是一种能在\(O(n \log n)\)的时间内完成多项式乘法的算法,在\(OI\)中的应用很多,是 ... 
- 【OI向】快速傅里叶变换(Fast Fourier Transform)
		[OI向]快速傅里叶变换(Fast Fourier Transform) FFT的作用  在学习一项算法之前,我们总该关心这个算法究竟是为了干什么.  (以下应用只针对OI)  一句话:求多项式 ... 
- Fast Fourier Transform
		写在前面的.. 感觉自己是应该学点新东西了.. 所以就挖个大坑,去学FFT了.. FFT是个啥? 挖个大坑,以后再补.. 推荐去看黑书<算法导论>,讲的很详细 例题选讲 1.UOJ #34 ... 
- Fast Fourier Transform ——快速傅里叶变换
		问题: 已知$A=a_{0..n-1}$, $B=b_{0..n-1}$, 求$C=c_{0..2n-2}$,使: $$c_i = \sum_{j=0}^ia_jb_{i-j}$$ 定义$C$是$A$ ... 
- 快速傅里叶变换(Fast Fourier Transform, FFT)和短时傅里叶变换(short-time Fourier transform,STFT )【资料整理】【自用】
		1. 官方形象展示FFT:https://www.bilibili.com/video/av19141078/?spm_id_from=333.788.b_636f6d6d656e74.6 2. 讲解 ... 
- Python FFT (Fast Fourier Transform)
		np.fft.fft import matplotlib.pyplot as plt import plotly.plotly as py import numpy as np # Learn abo ... 
随机推荐
- lintcode 中等题:Palindrome Linked List 回文链表
			题目 回文链表 设计一种方式检查一个链表是否为回文链表. 样例 1->2->1 就是一个回文链表. 挑战 O(n)的时间和O(1)的额外空间. 解题 法一: 再定义一个链表,存放链表反转的 ... 
- Orcle数据库查询练习复习:一
			一.创建数据库和表 drop table student; create table student ( sid int, sname ), sage int, ssex ), snativeplac ... 
- JavaWeb项目开发案例精粹-第2章投票系统-004action层
			1. package com.sanqing.action; import java.util.UUID; import com.opensymphony.xwork2.ActionSupport; ... 
- 输出进程相关联的环境变量信息(使用GetEnvironmentStrings取得信息,然后使用StringCchCopyN和StringCchPrintf保证字符串不会越界)
			void DumpEnvironmentStrings() { #define MAX_ENVIRONMENT_NAME_LENGTH (128) #define MAX_ENVIRONMEN ... 
- esriControlsMousePointer 控制鼠标指针
			axMapControl1.MousePointer = esriControlsMousePointer.esriPointerHourglass; 控制鼠标指针选项. 不变 值 描述 esriPo ... 
- WCF揭秘(一)——简单的WCF开发实例
			一.WCF是什么 WCF是微软为了实现各个开发平台之间的无疑缝连接而开发一种崭新工具,它是为分布式处理而开发.WCF将DCOM.Remoting.Web Service.WSE.MSMQ.AJAX服务 ... 
- HDU5086——Revenge of Segment Tree(BestCoder Round #16)
			Revenge of Segment Tree Problem DescriptionIn computer science, a segment tree is a tree data struct ... 
- C# 使用ManualResetEvent 进行线程同步
			上一篇我们介绍了AutoResetEvent,这一篇我们来看下ManualResetEvent ,顾名思义ManualResetEvent 为手动重置事件. AutoResetEvent和Manua ... 
- linux scp
			scp是 secure copy的缩写, scp是linux系统下基于ssh登陆进行安全的远程文件拷贝命令.linux的scp命令可以在linux服务器之间复制文件和目录. scp命令的用处: scp ... 
- Eclipse常见设置及快捷键使用总结(更新中)
			Eclipse中常见设置: 1.Eclipse在保存时设置自动去掉多余的import和格式化代码 路径: window --> preferences --> java --> Ed ... 
