Az alábbi letöltési lehetőségek közül választhatsz: (
segítség)
Típus: text/plain
Tartalmaz szöveget
Karakterkódolás: utf-8
Méret: 1 KB
package welcometocodejamszk;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
public class fg_welcome1 {
public static void main(String[] args) throws IOException {
new fg_welcome1().run();
}
String sub, main;
int count(int subPos, int mainPos) {
int res = 0;
if (subPos == sub.length()) {
res = 1;
} else if (mainPos == main.length()) {
res = 0;
} else {
if (mainPos < main.length() - 1) {
res = res + count(subPos, mainPos+1);
}
if (main.charAt(mainPos) == sub.charAt(subPos)) {
res = res + count(subPos+1, mainPos+1);
}
}
return res % 10000;
}
void run() throws IOException {
String code = "szakkor";
BufferedReader br = new BufferedReader(new FileReader("C-"+code+".in"));
PrintWriter pw = new PrintWriter(new FileWriter("C-"+code+".out"));
sub = br.readLine();
int N = Integer.parseInt(br.readLine());
for (int i = 1; i <= N; i++) {
main = br.readLine();
int res = count(0, 0);
pw.printf("Case #%1$d: %2$04d\n", i, res);
}
br.close();
pw.close();
}
}