Contest Duration: - (local time) (100 minutes) Back to Home

Submission #6569001

Source Code Expand

Copy
```import java.io.*;
import java.lang.reflect.Array;
import java.util.*;
import java.util.Map.Entry;
import java.util.function.Function;
import java.util.stream.Collectors;

@SuppressWarnings("unused")
public class Main {
FastScanner in = new FastScanner(System.in);
PrintWriter out = new PrintWriter(System.out);
final int MOD = (int)1e9+7;
void printlnYN(boolean b){out.println((b ? "YES" : "NO"));}

//System.out.println();はつかわない！！
void solve() throws Exception{
String X = in.nextStr();
long[][] dp = new long[X.length()+1][13];
dp[0][0] = 1;

for(int i = 0; i < X.length(); i++){
for(int m = 0; m < 13; m++){
if(X.charAt(i) != '?'){
int num = (X.charAt(i) - '0');
int nextM = (m * 10 + num) % 13;
dp[i+1][nextM] += dp[i][m];
dp[i+1][nextM] %= MOD;
}else{
for(int n = 0; n <= 9; n++){
int nextM = (m * 10 + n) % 13;
dp[i+1][nextM] += dp[i][m];
dp[i+1][nextM] %= MOD;
}
/*
for(int m = 0; m < 13; m++){
for(int nextD = 0; nextD <= ((j == 1) ? 9 : num); nextD++){
int nextJ = (j == 1 || nextD < num) ? 1 : 0;
int nextM = (m * 10 + nextD) % 13;
dp[i+1][nextJ][nextM] += dp[i][j][m];
dp[i+1][nextJ][nextM] %= MOD;
}
}
*/
}
}
}
out.println(dp[X.length()][5]);
}

public static void main(String[] args) throws Exception {
new Main().m();
}

void m() throws Exception {
solve();
out.flush();
}

class FastScanner {

FastScanner() {this(System.in);}

int nextInt() {return (int) nextLong();}

long nextLong() {
try {
int sign = 1;
while ((b < '0' || '9' < b) && b != '-' && b != '+') {
}
if (b == '-') {
sign = -1;
} else if (b == '+') {
}
long ret = b - '0';
while (true) {
if (b < '0' || '9' < b) return ret * sign;
ret *= 10;
ret += b - '0';
}
} catch (IOException e) {
e.printStackTrace();
return -1;
}
}

double nextDouble() {
try {
double sign = 1;
while ((b < '0' || '9' < b) && b != '-' && b != '+') {
}
if (b == '-') {
sign = -1;
} else if (b == '+') {
}
double ret = b - '0';
while (true) {
if (b < '0' || '9' < b) break;
ret *= 10;
ret += b - '0';
}
if (b != '.') return sign * ret;
double div = 1;
while ('0' <= b && b <= '9') {
ret *= 10;
ret += b - '0';
div *= 10;
}
return sign * ret / div;
} catch (IOException e) {
e.printStackTrace();
return Double.NaN;
}
}

char nextChar() {
try {
while (Character.isWhitespace(b)) {
}
return (char) b;
} catch (IOException e) {
e.printStackTrace();
return 0;
}
}

String nextStr() {
try {
StringBuilder sb = new StringBuilder();
while (Character.isWhitespace(b)) {
}
while (b != -1 && !Character.isWhitespace(b)) {
sb.append((char) b);
}
return sb.toString();
} catch (IOException e) {
e.printStackTrace();
return "";
}
}

public int[] nextIntArray(int n) {
int[] res = new int[n];
for (int i = 0; i < n; i++) {
res[i] = nextInt();
}
return res;
}

public int[] nextIntArrayDec(int n) {
int[] res = new int[n];
for (int i = 0; i < n; i++) {
res[i] = nextInt() - 1;
}
return res;
}

public int[] nextIntArray1Index(int n) {
int[] res = new int[n + 1];
for (int i = 0; i < n; i++) {
res[i + 1] = nextInt();
}
return res;
}

public long[] nextLongArray(int n) {
long[] res = new long[n];
for (int i = 0; i < n; i++) {
res[i] = nextLong();
}
return res;
}

public long[] nextLongArrayDec(int n) {
long[] res = new long[n];
for (int i = 0; i < n; i++) {
res[i] = nextLong() - 1;
}
return res;
}

public long[] nextLongArray1Index(int n) {
long[] res = new long[n + 1];
for (int i = 0; i < n; i++) {
res[i + 1] = nextLong();
}
return res;
}

public double[] nextDoubleArray(int n) {
double[] res = new double[n];
for (int i = 0; i < n; i++) {
res[i] = nextDouble();
}
return res;
}
}
}
/* end Main */```

#### Submission Info

Submission Time 2019-07-27 21:17:26+0900 D - Digits Parade Oland Java8 (OpenJDK 1.8.0) 400 4878 Byte AC 168 ms 35668 KB

#### Judge Result

Score / Max Score 0 / 0 400 / 400
Status
 AC × 4
 AC × 30
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
Subtask1 sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt, sub1_01.txt, sub1_02.txt, sub1_03.txt, sub1_04.txt, sub1_05.txt, sub1_06.txt, sub1_07.txt, sub1_08.txt, sub1_09.txt, sub1_10.txt, sub1_11.txt, sub1_12.txt, sub1_13.txt, sub1_14.txt, sub1_15.txt, sub1_16.txt, sub1_17.txt, sub1_18.txt, sub1_19.txt, sub1_20.txt, sub1_21.txt, sub1_22.txt, sub1_23.txt, sub1_24.txt, sub1_25.txt, sub1_26.txt
Case Name Status Exec Time Memory
sample_01.txt AC 69 ms 18516 KB
sample_02.txt AC 69 ms 18388 KB
sample_03.txt AC 70 ms 19412 KB
sample_04.txt AC 69 ms 20948 KB
sub1_01.txt AC 129 ms 26848 KB
sub1_02.txt AC 140 ms 26300 KB
sub1_03.txt AC 69 ms 19412 KB
sub1_04.txt AC 70 ms 20564 KB
sub1_05.txt AC 127 ms 27020 KB
sub1_06.txt AC 75 ms 19668 KB
sub1_07.txt AC 76 ms 21076 KB
sub1_08.txt AC 138 ms 30860 KB
sub1_09.txt AC 168 ms 33888 KB
sub1_10.txt AC 152 ms 24836 KB
sub1_11.txt AC 75 ms 19540 KB
sub1_12.txt AC 71 ms 20052 KB
sub1_13.txt AC 70 ms 19028 KB
sub1_14.txt AC 69 ms 17364 KB
sub1_15.txt AC 68 ms 18772 KB
sub1_16.txt AC 68 ms 17748 KB
sub1_17.txt AC 167 ms 31828 KB
sub1_18.txt AC 147 ms 33492 KB
sub1_19.txt AC 154 ms 34188 KB
sub1_20.txt AC 156 ms 31828 KB
sub1_21.txt AC 124 ms 35668 KB
sub1_22.txt AC 122 ms 33620 KB
sub1_23.txt AC 123 ms 35412 KB
sub1_24.txt AC 161 ms 33364 KB
sub1_25.txt AC 69 ms 18516 KB
sub1_26.txt AC 68 ms 20180 KB