当前位置:网站首页>313. super ugly number
313. super ugly number
2022-06-23 07:08:00 【Graduation_ Design】
Preface
C++ It's a high-level programming language , from C Language expansion and upgrading , As early as 1979 By Benjani · Strauss LUP is AT&T Developed by Bell studio .
C++ Both can be carried out C Process programming of language , It can also be used for object-based programming characterized by abstract data types , It can also carry out object-oriented programming characterized by inheritance and polymorphism .C++ Good at object-oriented programming at the same time , You can also do process based programming .
C++ Have the practical characteristics of computer operation , At the same time, it is also committed to improving the programming quality of large-scale programs and the problem description ability of programming languages .
Java Is an object-oriented programming language , Not only absorbed C++ The advantages of language , It's abandoned C++ The incomprehensible inheritance in 、 Concepts such as pointer , therefore Java Language has two characteristics: powerful and easy to use .Java As the representative of static object-oriented programming language , Excellent implementation of object-oriented theory , Allow programmers to do complex programming in an elegant way of thinking .
Java It's simple 、 object-oriented 、 Distributed 、 Robustness, 、 Security 、 Platform independence and portability 、 Multithreading 、 Dynamic and so on .Java Can write desktop applications 、Web Applications 、 Distributed system and embedded system applications, etc .
Python By Guido of the Dutch Society for mathematical and computer science research · Van rosum On 1990 It was designed in the early 's , As a course called ABC A substitute for language .Python Provides efficient advanced data structure , It's also a simple and effective way of object-oriented programming .Python Syntax and dynamic types , And the nature of interpretative language , Make it a programming language for scripting and rapid application development on most platforms , With the continuous update of the version and the addition of new language features , Gradually used for independent 、 Development of large projects .
Python The interpreter is easy to extend , have access to C Language or C++( Or something else can be done through C Calling language ) Expand new functions and data types .Python It can also be used as an extensible programming language in customizable software .Python Rich library of standards , Provides source code or machine code for each major system platform .
2021 year 10 month , Compiler for language popularity index Tiobe take Python Crowned the most popular programming language ,20 Put it in... For the first time in years Java、C and JavaScript above .
describe
Super ugly number Is a positive integer , And satisfy that all prime factors appear in the prime array primes in .
Give you an integer n And an array of integers primes , Back to page n individual Super ugly number .
Title Data assurance n individual Super ugly number stay 32-bit Signed integer range .
Example 1:
Input :n = 12, primes = [2,7,13,19]
Output :32
explain : Given length is 4 Array of prime numbers primes = [2,7,13,19], front 12 The sequence of super ugly numbers is :[1,2,4,7,8,13,14,16,19,26,28,32] .
Example 2:
Input :n = 1, primes = [2,3,5]
Output :1
explain :1 Without prime factor , So all its prime factors are in the prime array primes = [2,3,5] in .
class Solution {
public int nthSuperUglyNumber(int n, int[] primes) {
int[] dp = new int[n + 1];
int m = primes.length;
int[] pointers = new int[m];
int[] nums = new int[m];
Arrays.fill(nums, 1);
for (int i = 1; i <= n; i++) {
int minNum = Arrays.stream(nums).min().getAsInt();
dp[i] = minNum;
for (int j = 0; j < m; j++) {
if (nums[j] == minNum) {
pointers[j]++;
nums[j] = dp[pointers[j]] * primes[j];
}
}
}
return dp[n];
}
}
边栏推荐
- MySQL MVCC多版本并发控制
- 316. remove duplicate letters
- Project_ Filter to solve Chinese garbled code
- Analyzing the creation principle in maker Education
- 315. calculate the number of elements on the right that are smaller than the current element
- 【毕业季·进击的技术er】自己的选择,跪着也要走
- Some difficulties in making web pages
- 【STL】顺序容器之deque用法总结
- MySQL index
- 316. 去除重复字母
猜你喜欢

QT method of compiling projects using multithreading

Open source oauth2 framework for SSO single sign on

EndNote20使用教程分享(未完

Idea automatically generates serialVersionUID

【STL】顺序容器之deque用法总结

【STL】关联容器之unordered_map用法总结

QT设计师无法修改窗口大小,无法通过鼠标拖动窗口改变大小的解决方案

MySQL optimization

Traversal of binary tree and related knowledge

Idea installing the cloudtoolkit plug-in
随机推荐
Open source oauth2 framework for SSO single sign on
Lombok的使用
Mongodb record
Storage mode of data in memory (C language)
产品-Axure9(英文版),原型设计 制作下拉二级菜单
MySQL mvcc multi version concurrency control
EndNote20使用教程分享(未完
Why does TCP protocol shake hands three times instead of two?
MySQL function
897. 递增顺序搜索树
WPF command directive and inotifypropertychanged
[project training] multi segment line expanded to parallel line
Verilog syntax explanation
Intentional shared lock, intentional exclusive lock and deadlock of MySQL
Anti chicken soup speech
QT设计师无法修改窗口大小,无法通过鼠标拖动窗口改变大小的解决方案
GloRe
900. RLE 迭代器
在金融行业做数据产品经理是什么体验
【BULL中文文档】用于在 NodeJS 中处理分布式作业和消息的队列包