hdu 1895 Sum Zero hash
Sum Zero
Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)
For each test case, there are 5 lines Integers, In each line, the first one is the number of integers in its array.
3 4 -2 3
5 -5 -1 -7 -10 -1
5 -10 2 4 -6 2
2 -4 -1
5 -7 -7 -1 -4 -6
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<queue>
#include<algorithm>
#include<stack>
#include<cstring>
#include<vector>
#include<list>
#include<bitset>
#include<set>
#include<map>
#include<time.h>
using namespace std;
#define LL long long
#define bug(x) cout<<"bug"<<x<<endl;
const int N=5e4+,M=1e5+,inf=1e9+;
const LL INF=1e18+,mod=1e9+;
const double eps=(1e-),pi=(*atan(1.0)); int si[];
int a[][];
struct handhash
{
const static int side=1e5+;
vector<int>v[M];
vector<int>nu[M];
void init()
{
for(int i=;i<side;i++)
v[i].clear(),nu[i].clear();
}
void add(int x)
{
int z=(abs(x))%side;
for(int i=;i<v[z].size();i++)
if(v[z][i]==x)
{
nu[z][i]++;
return;
}
v[z].push_back(x);
nu[z].push_back();
}
int query(int x)
{
int z=(abs(x))%side;
for(int i=;i<v[z].size();i++)
if(v[z][i]==x)return nu[z][i];
return ;
}
}mp;
int main()
{
int T;
scanf("%d",&T);
while(T--)
{
mp.init();
for(int i=;i<=;i++)
{
scanf("%d",&si[i]);
for(int j=;j<=si[i];j++)
scanf("%d",&a[i][j]);
}
for(int i=;i<=si[];i++)
for(int j=;j<=si[];j++)
mp.add(a[][i]+a[][j]);
LL ans=;
for(int k=;k<=si[];k++)
for(int i=;i<=si[];i++)
for(int j=;j<=si[];j++)
ans+=mp.query(-a[][k]-a[][i]-a[][j]);
printf("%lld\n",ans%mod);
}
return ;
}
Sum Zero
Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)
Total Submission(s): 1055 Accepted Submission(s): 312
For each test case, there are 5 lines Integers, In each line, the first one is the number of integers in its array.
3 4 -2 3
5 -5 -1 -7 -10 -1
5 -10 2 4 -6 2
2 -4 -1
5 -7 -7 -1 -4 -6
hdu 1895 Sum Zero hash的更多相关文章
- HDU 1043 Eight (A* + HASH + 康托展开)
Eight Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Sub ...
- HDOJ(HDU).1258 Sum It Up (DFS)
HDOJ(HDU).1258 Sum It Up (DFS) [从零开始DFS(6)] 点我挑战题目 从零开始DFS HDOJ.1342 Lotto [从零开始DFS(0)] - DFS思想与框架/双 ...
- hdu 1258 Sum It Up(dfs+去重)
题目大意: 给你一个总和(total)和一列(list)整数,共n个整数,要求用这些整数相加,使相加的结果等于total,找出所有不相同的拼凑方法. 例如,total = 4,n = 6,list = ...
- HDU 4821 String (HASH)
题意:给你一串字符串s,再给你两个数字m l,问你s中可以分出多少个长度为m*l的子串,并且子串分成m个长度为l的串每个都不完全相同 首先使用BKDRHash方法把每个长度为l的子串预处理成一个数字, ...
- 数论 --- 费马小定理 + 快速幂 HDU 4704 Sum
Sum Problem's Link: http://acm.hdu.edu.cn/showproblem.php?pid=4704 Mean: 给定一个大整数N,求1到N中每个数的因式分解个数的 ...
- HDU 1231 最大连续子序列 &&HDU 1003Max Sum (区间dp问题)
C - 最大连续子序列 Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit ...
- HDU 4704 Sum (高精度+快速幂+费马小定理+二项式定理)
Sum Time Limit:1000MS Memory Limit:131072KB 64bit IO Format:%I64d & %I64u Submit Status ...
- HDU 4287 Intelligent IME hash
Intelligent IME Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?p ...
- HDU 5776 sum (模拟)
sum 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5776 Description Given a sequence, you're asked ...
随机推荐
- 注意兼容浮点运算误差 0.7 + 0.1 ==0.8 为false
所以比较 汇总或者计算的时候注意确定精度0.7 + 0.1 ==0.8 换成 Math.abs(0.7 + 0.1 ==0.8)<0.0001参考下
- (function(){…})(); 与 (function(){…}());
从结果上来说,个人的意见是:他们是一样的.
- 在Mac上 python中使用tesseract OCR (Pytesser) 识别图片中的文字
仓库地址:https://github.com/RobinDavid/Pytesser brew install tesseract sudo pip install opencv-python 安装 ...
- ES6 数值
数值的表示 二进制表示法新写法: 前缀 0b 或 0B . console.log(0b11 === 3); // true console.log(0B11 === 3); // true 八进制表 ...
- echart tootip使用技巧
1.关于混合折线图tooltip显示不同单位 formatter: function (params){ return params[0].name + '<br/>' + params ...
- 解决Windows下文件在Linux下打开出现乱码的问题
目录 问题 原理 解决 总结 参考资料 问题 前几天生病了,Java一直在看代码但是没跟着打,于是决定偷一波小小的懒,直接把教材的代码从Windows通过共享文件夹放到了Linux里面.但是编译的时候 ...
- windows----------如何修改windows服务器远程端口
远程连接并登录到 Windows 实例. 选择开始 > 运行,输入 regedit 打开注册表编辑器. 查找 HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSe ...
- beego 初体验 - 基础模块 - config, httplibs, logs
beego 的基础模块支持了一些web开发常用的功能. 配置,http操作库,日志 配置模块: 这是我的配置文件 如何读取: httplibs:这是一个利用 httplibs 发起 get 请求的示例 ...
- SQL 增加列、修改列、删除列
SQL语句增加列.修改列.删除列 1.增加列: alter table tableName add columnName varchar(30) 2.1. 修改列类型: alter table tab ...
- armv8 memory translation
AArch32,arm的32bit架构: AArch64,arm的64bit架构: ARMv8.2-LPA,是armv8.2中的新feature,扩大了IPA和PA的支持范围,从48bit扩展到52b ...