# 第十届蓝桥杯——JAVA真题集锦

第十届蓝桥杯JAVA真题

⭐不同子串⭐

⭐数列求值⭐

⭐数的分解⭐

⭐特别数的和⭐

## ⭐不同子串⭐

### 解题思路

hashmap的特点就是：如果有重复的字符串会覆盖之前的字符串

### 代码实现

``````import java.util.HashMap;

public class Main {
public static void main(String[] args) {
String s = "0100110001010001";
HashMap<String, Integer> map = new HashMap<>();

for (int i = 0; i <= s.length(); i++) {
for (int j = i+1; j <= s.length(); j++) {
map.put(s.substring(i, j), 1);
}
}

System.out.println(map.size());
}
}``````

## ⭐数列求值⭐

### 代码实现

``````  public class Main {
public static void main(String[] args) {

int a = 1,b = 1,c = 1;
for (int i = 4; i <= 20190324; i++) {
//为了防止超过最大整数，可以对100000取余
int temp = (a + b + c)%100000;
a = b%100000;
b = c%100000;
c = temp;
}

System.out.println(c);
}
}``````

## ⭐数的分解⭐

### 代码实现

``````public class Main {
public static void main(String[] args) {
int n = 2019;
int t = 0;
loop:for (int i = 1; i < n; i++) {
if((i+"").indexOf("2")!=-1||(i+"").indexOf("4")!=-1)
continue;
loop2:for (int j = i+1; j < n; j++) {
if(i==j)
continue loop2;
if((j+"").indexOf("2")!=-1||(j+"").indexOf("4")!=-1)
continue;
int k = n-i-j;
if(k<=0)
break loop2;
if(i==k)
continue loop2;
if(j==k)
continue loop2;
if((k+"").indexOf("2")!=-1||(k+"").indexOf("4")!=-1)
continue loop2;
t++;
}
}
System.out.println(t/3);
}
}``````

## ⭐特别数的和⭐

### 代码实现

``````import java.util.Scanner;

public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
long n = sc.nextInt();
long num = 0;

for (int i = 1; i <= n; i++) {
String s = i + "";
if(s.indexOf("2")!=-1||s.indexOf("0")!=-1||s.indexOf("1")!=-1||s.indexOf("9")!=-1)
num += i;
}
System.out.println(num);
}
}``````

这篇文章如果对小伙伴们有帮助的话，希望点个赞支持一下~      十分感谢~

THE END

)">