POJ-1804 Eqs 解题报告

POJ1840-Eqs 北大POJ1840-Eqs 解题报告+AC代码 立即下载

Description

Consider equations having the following form: 
a1x1 3+ a2x2 3+ a3x3 3+ a4x4 3+ a5x5 3=0 
The coefficients are given integers from the interval [-50,50]. 
It is consider a solution a system (x1, x2, x3, x4, x5) that verifies the equation, xi∈[-50,50], xi != 0, any i∈{1,2,3,4,5}. 

Determine how many solutions satisfy the given equation. 

Input

The only line of input contains the 5 coefficients a1, a2, a3, a4, a5, separated by blanks.

Output

The output will contain on the first line the number of the solutions for the given equation.

Sample Input

37 29 41 43 47

Sample Output

654


       题目链接:http://poj.org/problem?id=1840

       解法类型:hash

       解题思路:对方程变下形就可以了,然后直接建立hash表。这里有很多建立hash表的方法,可以直接暴力建立没有冲突情况的hash表,但内存会消耗很多。因此可以在建立时加冲突解决情况的处理,对其值取模,建立闭散性的hash表,极大地降低了内存的使用率,但同时带来了时间消耗的增加。

       算法实现:

//STATUS:C++_AC_2188MS_7948K
#include<stdio.h>
#include<string.h>
const int MAXN=999991;
int hash(int s);
int num[MAXN],saves[MAXN],p[110];
int main()
{
//	freopen("in.txt","r",stdin);
	int i,x1,x2,x3,x4,x5,a1,a2,a3,a4,a5,sum,t,ways;
	for(i=-50;i<0;i++)      //初始化
		p[i+50]=i*i*i;
	for(i=1;i<=50;i++)
		p[i+49]=i*i*i;
	
	while(~scanf("%d%d%d%d%d",&a1,&a2,&a3,&a4,&a5))
	{
		memset(num,0,sizeof(num));      
		memset(saves,0,sizeof(saves));

		for(x1=0;x1<100;x1++)           //hash表的构建
			for(x2=0;x2<100;x2++)
				for(x3=0;x3<100;x3++){
					sum=a1*p[x1]+a2*p[x2]+a3*p[x3];
					t=hash(sum);
					num[t]++;
					saves[t]=sum;
				}

		ways=0;
		for(x4=0;x4<100;x4++)            //hash表的查找
			for(x5=0;x5<100;x5++){
				sum=-(a4*p[x4]+a5*p[x5]);
				t=hash(sum);
				ways+=num[t];
			}
		printf("%d\n",ways);
	}
	return 0;
}

int hash(int s)
{
	int t=s%MAXN;
	if(t<0)t+=MAXN;
	while(num[t]!=0 && saves[t]!=s)  //hash表为空或者找到s
		t=(t+3)%MAXN;     //这里处理不好,会超时,看数据,看RP!
	return t;
}

携程景点评论数据爬取实战:破解AJAX动态加载与分页参数逆向分析 本文详细介绍了携程景点评论数据爬取的实战经验,重点破解了AJAX动态加载与分页参数逆向分析的技术难题。通过分析`getCommentCollapseList`接口,解析动态参数如`poiId`和`pageIndex`,并实现分页逻辑,帮助开发者高效获取评论数据。文章还提供了完整的Python爬虫代码和反爬策略,适用于数据分析与内容挖掘。 阅读详情

相关推荐

保姆级教程:用TIA Portal V17给S7-1200 PLC和HMI做个联调仿真(附抢答器完整项目包)

本文提供了一份详细的TIA Portal V17教程,指导如何实现S7-1200 PLC与HMI的联合仿真开发。通过抢答器项目实例,涵盖从环境搭建、PLC编程到HMI设计的全流程,帮助工程师高效完成工业自动化系统的虚拟调试,显著提升开发效率。

weixin_30417487的博客 624

Eqs(POJ--1840

Description Consider equations having the following form:  a1x13+ a2x23+ a3x33+ a4x43+ a5x53=0  The coefficients are given integers from the interval [-50,50].  It is consider a solution a system

zhang_di233的专栏 578

高效搭建微信公众号爬虫全流程

微信公众号爬虫系统成功完成功能测试验证。该系统具备完整的数据采集与管理能力,支持多公众号内容爬取、数据存储与统计分析。通过命令行界面可执行爬取操作(如量子位、新智元等公众号),查看最新文章列表和系统统计信息。测试显示SQLite数据库正常存储数据,所有核心功能(多源支持、文章检索、数据统计)均运行良好。系统采用模块化设计,扩展性强,为后续接入真实API或网页爬取奠定了坚实基础,是AI内容聚合的优质开发平台。🎉

weixin_44975687的博客 1554

哈希表应用:POJ1840 公式

题目描述: Consider equations having the following form: a1x13+ a2x23+ a3x33+ a4x43+ a5x53=0 The coefficients are given integers from the interval [-50,50]. It is consider a solution a system (x1, x2, x3, x4, x5) that verifies the equation, xi∈[-50,50], xi !=

qq_48988844的博客 422

从多项式到神经网络:DPD算法演进史及其在RRU中的工程实现

本文系统梳理了数字预失真(DPD)算法从经典多项式模型、查表法到神经网络驱动的演进历程,并深入探讨了其在基站射频单元(RRU)中面临的硬件资源约束与工程实现挑战。文章为通信设备的技术决策者提供了算法选型、性能权衡及混合架构设计的实用评估框架,助力在性能、功耗与成本间找到最优平衡。

cherry的博客 1076

MobaXterm隧道配置详解:为PyCharm远程开发打通‘最后一公里’

本文详细解析了如何利用MobaXterm配置SSH隧道,实现PyCharm远程开发的高效连接。通过本地端口转发技术,开发者可以安全访问内网服务器,特别适用于需要通过跳板机的复杂网络环境。文章涵盖从基础配置到企业级运维的全套解决方案,包括性能优化、安全加固等实用技巧。

weixin_30566063的博客 503

D - Eqs解题报告

Description Consider equations having the following form: a1x13+ a2x23+ a3x33+ a4x43+ a5x53=0 The coefficients are given integers from the interval [-50,50]. It is consider a solution a system

谢庆皇的专栏 518

如何用Deep OC-SORT提升多目标跟踪精度?实战配置与性能优化指南

本文是一份针对开发者的Deep OC-SORT多目标跟踪实战指南。详细解析了如何通过部署其核心的“动态外观记忆”与“相机防抖”模块来有效应对遮挡与抖动,从而显著提升跟踪精度与连续性。内容涵盖从环境搭建、参数调优到性能压榨的全流程,并提供针对不同场景的配置建议与工程落地技巧。

f9g0h的博客 670

ACM: 哈希暴力求解 哈希题 poj 184…

Eqs Description Consider equations having the following form: a1x13+ a2x23+ a3x33+ a4x43+ a5x53=0 The coefficients are given integers from the interval [-50,50]. It is consider a solution a system (x1

smile_benson 580

COMSOL新手必看:锂电池仿真从入门到精通的5个实战案例(附模型文件)

本文为COMSOL新手提供锂电池仿真的5个实战案例,涵盖锂枝晶生长模拟、电池热失控预警、SOC估计等效电路模型、电池组液冷系统热管理及SOH衰退模型构建。通过详细步骤和参数设置,帮助用户快速掌握锂电池仿真技术,提升新能源研发效率。附模型文件可直接应用。

wdx01234567的博客 260

2023华为od机试C卷【最富裕的小家庭】Java&Go 实现

在一颗树中,每个节点代表一个家庭成员,节点的数字表示其个人的财富值,一个节点及其直接相连的子节点被定义为个小家庭。现给你一颗树,请计算出最富裕的小家庭的财富和。

MISAYAONE的博客 1903

POJ 1840-Eqs(哈希-五元方程组解的个数)

Eqs Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 16095   Accepted: 7902 Description Consider equations having the following form:  a1x13+ a2x23+ a3x33+ a

Some. 959

uniapp - 详细手机端h5网页调用手机摄像头进行二维码识别扫描,在uniapp的H5移动端微信网页平台中,在浏览器中调用手机扫码功能详细教程,识别二维码并获取扫描结果(完整示例源码,一键复制即用

uniapp,h5,手机端网页,H5手机网页,uniapp开发h5实现扫码功能,uniapp微信h5网页扫码sdk使用教程,uniapp h5网页如何实现浏览器扫码,uniapp扫码功能怎么兼容h5_uniapph5怎么做扫码功能,uniapp的手机网页如何实现扫二维码一维码,浏览器H5实现js扫码,H5调用摄像头和扫一扫功能,亲测可用,H5调用本地摄像头实现扫一扫,uni-h5项目解决扫码功能,uniapp实现微信H5扫码,解决uniapp在H5端使用不能扫码问题,uni-app的h5扫码(二维码、条形码

✅ 精选推荐文章 1万+

Eqs (哈希)

Time Limit:5000MS Memory Limit:65536K Total Submissions:10695 Accepted:5185 Description Consider equations having the following form:a1x13+ a2x23+ a3x33+ a4x43...

anyi7265的博客 218

计算机控制技术及应用

《计算机控制技术及应用》通过总结作者的科研成果和吸收国内外的先进理论、方法和技术,以计算机控制系统的网络化、开放化、智能化和集成化发展趋势为主线索,主要介绍计算机控制系统的基本概念和计算机控制系统的典型形式,计算机控制系统的数学描述与基本分析方法,以及数字PID控制器、最少拍控制系统、达林算法、状态变量设计法等设计方法及其各种改进算法。重点突出计算机控制系统输入输出通道接口的设计方法和典型控制系统的设计案例与实现方法等。

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

poj 1804Brainman(树状数组)

题目连接:http://poj.org/problem?id=1804 题目解析:                        此题和 poj2299 Ultra-QuickSort(http://poj.org/problem?id=2299)一样, 属于树状数组的离散化的题目,就是求一组数据的逆序数。由于给的的数据不连 续而且还有负数就想到用树状数组的离

Infinite振 781

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

Eqs(hash初步)

EqsDescription: Consider equations having the following form: a1x13+ a2x23+ a3x33+ a4x43+ a5x53=0 The coefficients are given integers from the interval [-50,50]. It is consider a solution a syst

cax1165 507

【POJ】1840:Eqs【哈希表】

Eqs Time Limit:5000MS Memory Limit:65536K Total Submissions:18299 Accepted:8933 Description Consider equations having the following form:a1x13+ a2x23+ a3x33+ a4x43...

weixin_30587025的博客 251

POJ 1804(归并求逆序数)

题目链接:http://poj.org/problem?id=1804   题目大意:求逆序数   题目思路:使用归并,然后以左边为基准,如果a[i]&gt;a[j],那么i~mid肯定都&gt;a[j],因为归并求逆序数的同时其实也在归并排序,两部分是排好顺序的,所以mid-i+1就是这一片的逆序数。   以下是代码: #include&lt;iostream&gt; #incl...

smilestruggler_Fly To Higher 475

哈理工OJ—1013 Eqs(数学怪题)

http://acm.hrbust.edu.cn/index.php?m=ProblemSet&a=showProblem&problem_id=1013 Eqs Time Limit: 5000 MS Memory Limit: 65536 K Total Submit: 566(229 users) Total Accepted: 330(212 users) Rating:

linlinsong—ACM界蒟水! 1541

STL的应用 POJ 1840 Eqs 题解

题目: Description Consider equations having the following form: a1x13+ a2x23+ a3x33+ a4x43+ a5x53=0 The coefficients are given integers from the interval [-50,50]. It is consider a soluti...

diaozhijian9717的博客 280

POJ--Eqs

题目要求:给出五个数字x1, x2, x3, x4, x5求满足等式的x的值有多少种组合,其中x∈[-50, 0) ∪ (0, 50] 思路:首先考虑暴力的情况是五重for循环就是10亿的复杂度,一定会TLE,但是如果把他们分成两部分,第一部分求得x1,x2,x3的所有组合,然后求得x4,x5的所有组合,想对应的组合使用乘法就可以了。计算量:10000000刚刚好。 #include #inc

shuimu12345678的专栏 793

POJ-1840 Eqs 解题报告

Description Consider equations having the following form: a1x13+ a2x23+ a3x33+ a4x43+ a5x53=0 The coefficients are given integers from the interval [-50,50]. It is consider a solution a system (

我要变强!直到我的名字响彻天堂! 798

Eqs POJ - 1840 hash表

题意是给出一个五元三次方程组的五个系数 求共有多少组解 题目限制时间是5000Ms 如果直接用暴力求解的话5层循环,每层100次,100的5次方,肯定不行 转换一下方程组 -(a*x1*x*x1+b*x2*x2*x2)=c*x3*x3*x3+d*x4*x4*x4+e*x5*x5*x5 这样就降到了100的三次方,100万 然后我们用hash映射,将前面的结果算出来映射到has

ices_的博客 460

poj1840——Eqs(哈希)

DescriptionConsider equations having the following form: a1x13+ a2x23+ a3x33+ a4x43+ a5x53=0 The coefficients are given integers from the interval [-50,50]. It is consider a solution a system (x1

Beyond the Sora 791

POJ 1840 Eqs

唉,我的入门“hash” 题目链接:http://poj.org/problem?id=1840 CSUST 2012年暑假8月组队后第十二次个人赛:http://acm.hust.edu.cn:8080/judge/contest/view.action?cid=11900#problem/B Eqs Time Limit: 5000MS   Memory L

free斩 1154

poj-1840 Eqs 暴力+哈希

Description Consider equations having the following form: a1x13+ a2x23+ a3x33+ a4x43+ a5x53=0 The coefficients are given integers from the interval [-50,50]. It is consider a solution a system (x1

心の コード 1056

Hrbust哈理工oj1013——Eqs

Description Consider equations having the following form: a1x13+ a2x23+ a3x33+ a4x43+ a5x53=0 The coefficients are given integers from the interval [-50,50]. It is consider a solution a...

连长少尉 349
上一篇: POJ-2503 Babelfish 解题报告
下一篇: POJ-1094 Sorting It All Out 解题报告
angle555945
博客等级 码龄15年 66粉丝 74原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值