XTOJ1250Super Fast Fourier Transform
来源:互联网 发布:淘宝怎么开直播卖衣服 编辑:程序博客网 时间:2024/05/20 11:25
链接:http://202.197.224.59/OnlineJudge2/index.php/Problem/read/id/1250
题意:给定两个数组a,b,计算sigma(i,j) (int)sqrt(abs(a[i]-b[j])),a,b数组的和都<=1e6。
分析:因为a数组的和<=1e6,所以不同的数字最多有1000个,同理b数组也是,然后只要将所有的数1e3*1e3统计一下就行了。
代码:
#include<map>#include<set>#include<cmath>#include<queue>#include<bitset>#include<math.h>#include<cstdio>#include<vector>#include<string>#include<cstring>#include<iostream>#include<algorithm>#pragma comment(linker, "/STACK:102400000,102400000")using namespace std;const int N=100010;const int MAX=1000000100;const int mod=100000000;const int MOD1=1000000007;const int MOD2=1000000009;const double EPS=0.00000001;typedef long long ll;const ll MOD=998244353;const int INF=1000000010;const double pi=acos(-1.0);typedef double db;typedef unsigned long long ull;int a[2][1010],b[2][1010],g[N*10];int main(){ int i,j,n,m,x,tota,totb; ll ans; while (scanf("%d%d", &n, &m)!=EOF) { memset(a,0,sizeof(a)); memset(b,0,sizeof(b)); tota=totb=0; memset(g,0,sizeof(g)); for (i=1;i<=n;i++) { scanf("%d", &x);g[x]++; } for (i=0;i<=1000000;i++) if (g[i]) { tota++;a[0][tota]=g[i];a[1][tota]=i; } memset(g,0,sizeof(g)); for (i=1;i<=m;i++) { scanf("%d", &x);g[x]++; } for (i=0;i<=1000000;i++) if (g[i]) { totb++;b[0][totb]=g[i];b[1][totb]=i; } ans=0LL; for (i=1;i<=tota;i++) for (j=1;j<=totb;j++) ans+=(ll)a[0][i]*b[0][j]*((ll)sqrt(abs(a[1][i]-b[1][j]))); printf("%lld\n", ans); } return 0;}
0 0
- XTOJ1250Super Fast Fourier Transform
- 【翻译】Fast Fourier Transform
- Fast Fourier Transform
- Fast Fourier Transform
- Fast Fourier Transform
- Fast Fourier Transform
- FFT (Fast Fourier Transform) 与 DFT (Discrete Fourier Transform)
- FFT (Fast Fourier Transform) 与 DFT (Discrete Fourier Transform)
- 快速傅立叶变换(Fast Fourier Transform)
- 快速傅立叶变换(Fast Fourier Transform)
- 湘潭oj_1250 Super Fast Fourier Transform
- XTU 1250 Super Fast Fourier Transform
- FFT(Fast Fourier transform 快速傅里叶变换)
- XTU 1250 Super Fast Fourier Transform 暴力 解题报告
- Fourier Transform
- Fourier Transform
- Fourier Transform
- Fourier Transform
- 用二分法找到数组山峰值
- android 请求权限被拒处理方法(使用于6.0以下系统)
- C++四种强制转换
- Cmake-add_subdirectory
- Scala各种符号的含义
- XTOJ1250Super Fast Fourier Transform
- SQLite在iOS中的使用
- js ==与===区别(两个等号与三个等号)
- IT工作方式与学习
- c的信号处理sigaction
- SVN 服务器地址的变更
- Implicit intents with startService are not safe错误的解决方式(转)
- AppBarLayout
- 使用toolbar 注意事项