当前位置:网站首页>求解多元多次方程解的个数
求解多元多次方程解的个数
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);
}
}
六 测试

边栏推荐
猜你喜欢
How to choose Visibility, Display, and Opacity when interacting or animating
C Expert Programming Preface
回收租凭系统100%开源无加密 商城+回收+租赁
可视化——Superset使用
【力扣】字符串相乘
kubernetes CoreDNS全解析
File operations of WEB penetration
ImportError: `save_weights` requires h5py. Problem solved
groupByKey和reduceBykey的区别
找工作必备!如何让面试官对你刮目相看,建议收藏尝试!!
随机推荐
C pitfalls and pitfalls Chapter 8 Suggestions and answers 8.2 Answers
C Expert Programming Chapter 1 C: Through the Fog of Time and Space 1.3 The Standard I/O Library and the C Preprocessor
方舟:生存进化官服和私服区别
HCIP---Multiple Spanning Tree Protocol related knowledge points
图像融合GANMcC学习笔记
10 Practical Uses of NFTs (NFT System Development)
教你VSCode如何快速对齐代码、格式化代码
C Pitfalls and Defects Chapter 7 Portability Defects 7.9 Case Conversion
Homework 8.1 Orphans and Zombies
[Chinese tree tags - CTB]
”sed“ shell脚本三剑客
包含吲哚菁绿的多聚体白蛋白纳米球/载马钱子碱纳米粒的牛血清白蛋白微球的制备
ModuleNotFoundError: No module named 'yaml'
【建议收藏】ヾ(^▽^*)))全网最全输入输出格式符整理
ImportError: `save_weights` requires h5py. Problem solved
Uses of Anacoda
PX4模块设计之十五:PX4 Log设计
宝塔应用使用心得
Shell programming conditional statement
C Pitfalls and pitfalls Appendix B Interview with Koenig and Moo