Sum Zero

Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)

Problem Description
There are 5 Integer Arrays and each of them contains no more than 300 integers whose value are between -100,000,000 and 100,000,000, You are to find how many such groups (i,j,k,l,m) can make A[0][i]+A[1][j]+A[2][k]+A[3][l]+A[4][m]=0. Maybe the result is too large, you only need tell me the remainder after divided by 1000000007.
 
Input
In the first line, there is an Integer T(0<T<20), means the test cases in the input file, then followed by T test cases. 
For each test case, there are 5 lines Integers, In each line, the first one is the number of integers in its array. 
 
Output
For each test case, just output the result, followed by a newline character.
 
Sample Input
1
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
 
Sample Output
11
 
Author
Sempr|CrazyBird|hust07p43
 
Source
#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

Problem Description
There are 5 Integer Arrays and each of them contains no more than 300 integers whose value are between -100,000,000 and 100,000,000, You are to find how many such groups (i,j,k,l,m) can make A[0][i]+A[1][j]+A[2][k]+A[3][l]+A[4][m]=0. Maybe the result is too large, you only need tell me the remainder after divided by 1000000007.
 
Input
In the first line, there is an Integer T(0<T<20), means the test cases in the input file, then followed by T test cases. 
For each test case, there are 5 lines Integers, In each line, the first one is the number of integers in its array. 
 
Output
For each test case, just output the result, followed by a newline character.
 
Sample Input
1
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
 
Sample Output
11
 
Author
Sempr|CrazyBird|hust07p43
 
Source

hdu 1895 Sum Zero hash的更多相关文章

  1. HDU 1043 Eight (A* + HASH + 康托展开)

    Eight Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Sub ...

  2. HDOJ(HDU).1258 Sum It Up (DFS)

    HDOJ(HDU).1258 Sum It Up (DFS) [从零开始DFS(6)] 点我挑战题目 从零开始DFS HDOJ.1342 Lotto [从零开始DFS(0)] - DFS思想与框架/双 ...

  3. hdu 1258 Sum It Up(dfs+去重)

    题目大意: 给你一个总和(total)和一列(list)整数,共n个整数,要求用这些整数相加,使相加的结果等于total,找出所有不相同的拼凑方法. 例如,total = 4,n = 6,list = ...

  4. HDU 4821 String (HASH)

    题意:给你一串字符串s,再给你两个数字m l,问你s中可以分出多少个长度为m*l的子串,并且子串分成m个长度为l的串每个都不完全相同 首先使用BKDRHash方法把每个长度为l的子串预处理成一个数字, ...

  5. 数论 --- 费马小定理 + 快速幂 HDU 4704 Sum

    Sum Problem's Link:   http://acm.hdu.edu.cn/showproblem.php?pid=4704 Mean: 给定一个大整数N,求1到N中每个数的因式分解个数的 ...

  6. HDU 1231 最大连续子序列 &&HDU 1003Max Sum (区间dp问题)

    C - 最大连续子序列 Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit ...

  7. HDU 4704 Sum (高精度+快速幂+费马小定理+二项式定理)

    Sum Time Limit:1000MS     Memory Limit:131072KB     64bit IO Format:%I64d & %I64u Submit Status  ...

  8. HDU 4287 Intelligent IME hash

    Intelligent IME Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?p ...

  9. HDU 5776 sum (模拟)

    sum 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5776 Description Given a sequence, you're asked ...

随机推荐

  1. 利用excel模板,将数据填充到excel中

    package com.excel;import java.io.File;import java.io.FileInputStream;import java.io.FileNotFoundExce ...

  2. SQL Server 2008作业失败:无法确定所有者是否有服务器访问权限

    转自:http://www.mzwu.com/article.asp?id=3592 下午准备将服务器数据导一份到本地,连上服务器找数据库备份文件发现最后一次备份是7月1日,竟然十几天没生成新备份,查 ...

  3. vue基本语法

    使用"{{ }}"来插入文本 使用v-html来插入html元素 v-bind给元素绑定属性,例如下面的,将title属性指定为data.title相同的值.v-bind指令后面的 ...

  4. The missing package manager for macOS (or Linux)

    The missing package manager for macOS (or Linux) — Homebrew https://brew.sh/

  5. [yum] yum加速

    通常,以我对于个人生活和工作品质的要求,并没有这个需求. 因为我的宽带费很贵,独享.就算是centos主站,也很快.但是当你去了一些办公环境恶劣的地方上班的时候, 也难免动用一些小技巧.如下: 装这个 ...

  6. Python+Django 后台view异步接不到参数问题

    因为后台需获取前台的多个ID参数(checkbox) //获取checkbox的每个ID并放到数组内var _items = []; var items = document.getElementsB ...

  7. 3、LwIP协议栈规范翻译——概述

    3.概述 像许多其他TCP/IP实现一样,分层协议设计已经成为设计lwIP实现的指南.每个协议实现为自己的模块,其中几个功能充当每个协议的入口点.尽管协议层是单独实现的,一些层却不全是,正如前面所叙述 ...

  8. VoiceXML简介

    简单来说,VoiceXML就是语音网络世界的HTML,一种用于语音应用的开放标准的标记语言.VoiceXML的问世使得为HTML发展起来的web体系也能够轻松地创建和使用语音应用. 发展历史: 199 ...

  9. 一个ping大包不通问题的解决过程

    1.问题描述 存在问题: 深圳的采集机MQ程序无法与应用服务器进行通讯,表现为:获取小数据时正常,获取大数据时超时 场景图如下 2.数据下载测试 使用SCP工具和FTP工具进行数据下载测试,主要是想排 ...

  10. SQL Server 之 事务与隔离级别实例讲解

    SQL Server 之 事务与隔离级别实例讲解 SQL Server 实现了6个隔离级别来防止并发情况下,类似企图并发的访问或修改同一数据时问题的发生.本文将带你体验全部6个隔离级别.正如你接下来将 ...