直接完成

master
sikadi 2023-09-27 19:47:13 +08:00
commit 8e1486597c
7 changed files with 96 additions and 0 deletions

29
.gitignore vendored 100644
View File

@ -0,0 +1,29 @@
### IntelliJ IDEA ###
out/
!**/src/main/**/out/
!**/src/test/**/out/
### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
### VS Code ###
.vscode/
### Mac OS ###
.DS_Store

8
.idea/.gitignore vendored 100644
View File

@ -0,0 +1,8 @@
# 默认忽略的文件
/shelf/
/workspace.xml
# 基于编辑器的 HTTP 客户端请求
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

6
.idea/misc.xml 100644
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/holiday05.iml" filepath="$PROJECT_DIR$/holiday05.iml" />
</modules>
</component>
</project>

6
.idea/vcs.xml 100644
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

11
holiday05.iml 100644
View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

28
src/Main.java 100644
View File

@ -0,0 +1,28 @@
import java.util.Arrays;
public class Main {
public static void main(String[] args) {
int[] arrArly = {2,3,3,5,6,8,9,0,6,7,2,3,4,5,7,2,3,5,8,4,2,5,4,4,3,5,7,7,4,7,7,8,3,6,7,9,6,6,9,6};
int length = arrArly.length;
int[] ds = new int[length];
Arrays.fill(ds,Integer.MAX_VALUE);
ds[0] =0;
for (int i = 1; i < length; i++) {
for (int j = 0; j < i; j++) {
if(j+arrArly[j] >=i) {
ds[i] = Math.min(ds[i], ds[j] + 1);
}
}
}
System.out.println(ds[length-1]);
}
}