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 ...
随机推荐
- CodeFirst简单演示的步骤
CodeFirst简单演示的步骤 创建实体类[Student] public class Student { public long Id { get; set; } public string Na ...
- asp.net NPOI导出xlsx格式文件,打开文件报“Excel 已完成文件级验证和修复。此工作簿的某些部分可能已被修复或丢弃”
NPOI导出xlsx格式文件,会出现如下情况: 点击“是”: 导出代码如下: /// <summary> /// 将datatable数据写入excel并下载 /// </summa ...
- zabbix结合grafana打造炫酷监控界面
一.grafana介绍 grafana是一个开源的数据展示工具, 是一个开箱即用的可视化工具,具有功能齐全的度量仪表盘和图形编辑器,有灵活丰富的图形化选项,可以混合多种风格,支持多个数据源特点. za ...
- [js]js设计模式-工厂模式
// 定义一个人 var p1 = { name: 'wxb', age: 22, writejs: function () { console.log(this.name + ' can sing. ...
- 从零开始一起学习SLAM | 点云平滑法线估计
点击公众号"计算机视觉life"关注,置顶星标更快接收消息! 本文编程练习框架及数据获取方法见文末获取方式 菜单栏点击"知识星球"查看「从零开始学习SLAM」一 ...
- cocos2d-x 编译 安卓(android)apk文件
摘要: 一.下载Android环境 搭建Android环境需要用到Android SDK.NDK.Ant和JDK: 下载Android SDK 下载Android NDk 下载Android JD ...
- 对象缓冲池 ( cc.pool ) :
对象缓冲池 ( cc.pool ) : 作用 : 优化创建效率 , 尤其是针对需要多次创建的情况 . 缓冲池 API : 缓冲池 ( cc.pool ) 提供的函数并不多 , 只有5个 . cc.po ...
- 钉钉调试应用Inspect不显示或显示空白的解决方法
首先必须使用钉钉开发版,并确保已经通过此链接打开了调试功能: https://open-doc.dingtalk.com/docs/doc.htm?spm=5176.10694750.0.0.3tPH ...
- Linux平台 Oracle 18c RAC安装Part2:GI配置
三.GI(Grid Infrastructure)安装 3.1 解压GI的安装包 3.2 安装配置Xmanager软件 3.3 共享存储LUN的赋权 3.4 使用Xmanager图形化界面配置GI 3 ...
- 函数作用域之闭包与this!
函数基础友情链接:http://speakingjs.com/es5/ch01.html#_functions 作用域链图解 var x = 1; function foo(){ var ...