public class Main {
public static void main(String[] args) {
int res = 0;
for(int i=1;i<=100000000;i++) {
String s = i+"";
char[] c = s.toCharArray();
int sum1 = 0;
int sum2 = 0;
if(c.length%2 == 0) {
for(int j1=0;j1<c.length/2;j1++) {
int jj1 = Integer.parseInt(c[j1]+"");
sum1+=jj1;
}
for(int j2=c.length/2;j2<c.length;j2++) {
int jj2 = Integer.parseInt(c[j2]+"");
sum2+=jj2;
}
if(sum1 == sum2) {
res++;
}
}
}
System.out.println(res);//4430091
}
}
P8649 [蓝桥杯 2017 省 B] k 倍区间
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int k = sc.nextInt();
int[] res = new int[n+1];
long sum = 0;
for(int i=1;i<=n;i++) {
res[i] = sc.nextInt();
if(res[i]%k == 0)
sum++;
}
for(int i=1;i<=n;i++) {
long num = res[i];
for(int j=i+1;j<=n;j++) {
num+=res[j];
if(num % k == 0) {
sum++;
}
}
}
System.out.println(sum);
}
}