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 ...
随机推荐
- vue2.0 vs vue
vue2.0相比vue1.0 有哪些改变,今天总结了一下 vue2.0组件中 template 不在支持代码片段 //vue1.0组件中template写法 <template> < ...
- Python学习之旅(三十五)
Python基础知识(34):电子邮件(Ⅰ) 几乎所有的编程语言都支持发送和接收电子邮件 在使用Python收发邮件前,请先准备好至少两个电子邮件,如xxx@163.com,xxx@sina.com, ...
- MOT北京站 | 卓越研发之路:亿万级云端架构演进
随着IT行业技术周期的快速迭代,如何在激烈的市场竞争中突出重围成为了不少技术人的困惑.除了要保持良好的技术视野外,多向IT行业精英学习他们分享的实战经验,也可让技术提升,达到事半功倍的效果. MOT北 ...
- kubernetes 1.3 使用skydns + kube2dns +etcd部署DNS服务器
1. 直接从Docker中拉取skydns,kube2dns,etcd容器,放到一个Pod中 kube2sky:1.14 etcd:2.0.9 skydns-amd64 2. 创建RC apiVers ...
- Grafana 安装及 Windows 应用程序服务配置工具 NSSM使用
网址:https://blog.csdn.net/kk185800961/article/details/83515382 1.进入conf文件,将 defaults.ini 复制一份,命名为cust ...
- 更新node的版本,node没有安装到c盘,安装到了D盘
百度的很久,只有这一个实用,记录一下 https://www.cnblogs.com/xinjie-just/p/7061619.html
- asp.net重要小知识
1.服务端用request获取值一般用的是name属性,而ID属性是获取不到值的.对于asp.net中服务器控件一般是把name属性封装的名字和ID相同.
- char 类型的操作函数
1.内存充填 void *memset(void *s,int ch,size_t n); 是由C Run-time Library提供的提供的函数,作用是在一段内存块中填充某个给定的值,它是对较大的 ...
- linux----------linux下配置内网ip
1./etc/sysconfig/network-scripts/ifcfg-eth1 创建这个文件里面的内容如下 TYPE="Ethernet" BOOTPROTO=&quo ...
- 解析web应用处理流程
客户端(浏览器.app.ajax.爬虫程序)通过域名(dns绑定)向服务器发送http协议,域名可以泛解析到机群.机器,服务器接收http请求报文,通过WSGI协议链接框架做代码逻辑层的处理,解析完逻 ...