当前位置:网站首页>number of solutions to solve a multivariate multi-degree equation
number of solutions to solve a multivariate multi-degree equation
2022-08-01 21:47:00 【Chengqiuming】
A link to the original question
Two Inputs and Outputs
1 input
2 output
Three input and output samples
1 Input example
37 29 41 43 47
2 Sample output
654
Four Analysis and Design
= 0 changes to
= -(
), This will change from a 5-layer loop to a 3-layer loop.The left or right values of the equation are violently enumerated and stored in the hash table. Since there may be negative values, let the negative value +25000000 be converted into a positive number, and the uniqueness of the value is guaranteed.Then brute force the other side of the equation.Store the value corresponding to the hash table directly in the ans accumulator, and finally output ans.Five codes
package poj1840;import java.util.Scanner;public class POJ1840 {static int maxn = 25000000 + 10;// The array is too large to use int (about 1677w for int array), use short arraystatic short hash[] = new short[maxn];static int a1, a2, a3, a4, a5;public static void main(String[] args) {int ans, temp;Scanner scanner = new Scanner(System.in);a1 = scanner.nextInt();a2 = scanner.nextInt();a3 = scanner.nextInt();a4 = scanner.nextInt();a5 = scanner.nextInt();ans = 0;for (int i = -50; i <= 50; i++)for (int j = -50; j <= 50; j++) {if (i == 0 || j == 0) continue;temp = (a1 * i * i * i + a2 * j * j * j) * (-1);if (temp < 0)temp = temp + maxn;hash[temp]++;}for (int i = -50; i <= 50; i++)for (int j = -50; j <= 50; j++)for (int k = -50; k <= 50; k++) {if (i == 0 || j == 0 || k == 0) continue;temp = a3 * i * i * i + a4 * j * j * j + a5 * k * k * k;if (temp < 0)temp = temp + maxn;if (hash[temp] > 0)ans = ans + hash[temp];}System.out.println(ans);}}Six Tests

边栏推荐
- LVS负载均衡群集
- 易周金融分析 | 银行ATM机智能化改造提速;互联网贷款新规带来挑战
- 【Jmeter常用断言组件】
- FusionGAN:A generative adversarial network for infrared and visible image fusion文章学习笔记
- Port protocol for WEB penetration
- 程序员必备的 “ 摸鱼神器 ” 来了 !
- Spark shuffle tuning
- 365 days challenge LeetCode1000 questions - Day 046 Generate a string with odd number of each character + add two numbers + valid parentheses
- VGUgarbage collector(垃圾回收器)的实现原理
- scikit-learn no moudule named six
猜你喜欢

方舟:生存进化官服和私服区别

今年的很美味

基于php影视资讯网站管理系统获取(php毕业设计)

Anacoda的用途

shell specification and variables

kubernetes CoreDNS全解析

高等代数_证明_矩阵的任意特征值的代数重数大于等于其几何重数

Based on php online examination management system acquisition (php graduation design)

2022-08-01 第五小组 顾祥全 学习笔记 day25-枚举与泛型

shell programming conventions and variables
随机推荐
C expert programming
C Pitfalls and Defects Chapter 7 Portability Defects 7.6 Memory Location 0
Port protocol for WEB penetration
迁移学习——Discriminative Transfer Subspace Learning via Low-Rank and Sparse Representation
基于php影视资讯网站管理系统获取(php毕业设计)
如何优雅的性能调优,分享一线大佬性能调优的心路历程
Pytest: begin to use
数据库练习
Uses of Anacoda
作业8.1 孤儿进程与僵尸进程
Spark shuffle tuning
树莓派的信息显示小屏幕,显示时间、IP地址、CPU信息、内存信息(c语言),四线的i2c通信,0.96寸oled屏幕
【Objective-C中的@synthesize】
scikit-learn no moudule named six
宝塔应用使用心得
数据分析面试手册《指标篇》
shell specification and variables
Jmeter combat | Repeated and concurrently grabbing red envelopes with the same user
C Expert Programming Chapter 1 C: Through the Fog of Time and Space 1.1 The Prehistoric Phase of the C Language
NFT的10种实际用途(NFT系统开发)