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. javascript的数组之find()

    find()方法返回数组中第一个满足回调函数测试的第一个元素的值.否则返回undefined const arr1 = [1, 2, 3, 4, 6, 9]; let found = arr1.fin ...

  2. Eclipse+pydev+手动安装

    1.Eclipse中手动安装pydev插件 解决:Eclipse版本中的windows-performance下面无法显示pydev的情况 1.Eclipse版本是:Version: Luna Ser ...

  3. Django + Axios & Ajax post和get 传参

    话说千遍淡如水,不如代码来一通.   Axios post: let params = new URLSearchParams(); params.append('id',xx) axios({ ur ...

  4. FPGA总结——杂谈

    数字设计   一.关于组合逻辑 竞争冒险:一个逻辑门的多个输入信号同时跳变(路径时延不同,使得状态改变的时刻有先有后).这种现象叫做竞争,引起的结果称为冒险. 消除毛刺(冒险):(1)增加冗余项:(2 ...

  5. 手写RPC框架

    https://www.bilibili.com/video/av23508597?from=search&seid=6870947260580707913 https://github.co ...

  6. DAX/PowerBI系列 - 累计总计(Cumulative Total)

    DAX/PowerBI系列 - 累计总计(Cumulative Total) 2017/07/23 更新:B列公式(见最后) 难度: ★★☆☆☆(2星) 适用: ★★☆☆☆(2星) 概况: 这个模式普 ...

  7. ASP.NET Core 之 Identity

    Claims:声明(证件单元)Identity:身份Principal:当事人Authentication :认证Authorization:授权 http://www.cnblogs.com/sav ...

  8. .net core 配置

    .net core 配置包括很多种 例如内存变量.命令行参数.环境变量以及物理文件配置和自定义配置 物理文件配置主要有三种,它们分别是JSON.XML和INI,对应的配置源类型分别是JsonConfi ...

  9. nuxtjs中使用路由守卫

    在vue中的路由守卫一般是来验证token失效什么的,当然也可以设置权限啦,在nuxtjs中如何使用路由守卫呢,话不多说,直接上代码 在plugins目录下简历route.js export defa ...

  10. Why Choose MB SD C5 with Engineer Software

    MB SD C5 with engineer software performed good and now is released. Unlike the old clone C5 which us ...