当前位置:网站首页>求解多元多次方程解的个数
求解多元多次方程解的个数
2022-08-01 21:35:00 【chengqiuming】
一 原问题链接
二 输入和输出
1 输入
2 输出
三 输入和输出样例
1 输入样例
37 29 41 43 47
2 输出样例
654
四 分析和设计



五 代码
package poj1840;
import java.util.Scanner;
public class POJ1840 {
static int maxn = 25000000 + 10;
// 数组太大,不能用int(int型数组1677w左右),用short型数组
static 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);
}
}
六 测试

边栏推荐
- C语言必杀技3行代码把运行速度提升4倍
- 测试开发人均年薪30w+?软件测试工程师如何进阶拿到高薪?
- NFT的10种实际用途(NFT系统开发)
- AI应用第一课:支付宝刷脸登录
- C Expert Programming Chapter 1 C: Through the Fog of Time and Space 1.3 The Standard I/O Library and the C Preprocessor
- P7215 [JOISC2020] 首都 题解
- ARFoundation Getting Started Tutorial U2-AR Scene Screenshot Screenshot
- 图像融合GANMcC学习笔记
- WEB 渗透之端口协议
- 关于npm的那些事儿
猜你喜欢
ARFoundation Getting Started Tutorial U2-AR Scene Screenshot Screenshot
19 Lectures on Disassembly of Multi-merchant Mall System Functions - Invoice Management on the Platform
方舟:生存进化PVE模式和PVP模式
图像融合GANMcC学习笔记
牛血清白蛋白-葡聚糖-叶黄素纳米颗粒/半乳糖白蛋白磁性阿霉素纳米粒的制备
Unity Shader 常规光照模型代码整理
小程序--分包
C语言_枚举类型介绍
AIDL通信
多商户商城系统功能拆解19讲-平台端发票管理
随机推荐
Based on php online music website management system acquisition (php graduation design)
多商户商城系统功能拆解19讲-平台端发票管理
【C语言实现】最大公约数的3种求法
365天挑战LeetCode1000题——Day 046 生成每种字符都是奇数个的字符串 + 两数相加 + 有效的括号
groupByKey和reduceBykey的区别
render-props和高阶组件
ARFoundation Getting Started Tutorial U2-AR Scene Screenshot Screenshot
2022牛客多校联赛第五场 题解
LeetCode952三部曲之一:解题思路和初级解法(137ms,超39%)
AI应用第一课:支付宝刷脸登录
Unity Shader general lighting model code finishing
JVM内存结构详解
C expert programming
【力扣】字符串相乘
微软校园大使喊你来秋招啦!
scikit-learn no moudule named six
The difference between groupByKey and reduceBykey
shell programming conventions and variables
shell脚本
ARFoundation入门教程U2-AR场景截图截屏