package practiceofcsp;
import java.util.Scanner;
public class CSP201312_4 {
static long result=0;
static int n;
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
n=sc.nextInt();
dfs("2");
System.out.println(result);
}
static void dfs(String s) {
int t0=s.lastIndexOf('0');
int t1=s.indexOf('1');
int t2=s.lastIndexOf('2');
int t3=s.indexOf('3');
if(t0!=-1&&t1!=-1&&t0>t1) {
return;
}
if(t2!=-1&&t3!=-1&&t2>t3) {
return ;
}
if(s.length()==n) {
if(t0!=-1&&t1!=-1&&t2!=-1&&t3!=-1) {
result=(result+1)%1000000007;
}
return ;
}
for(int i=0;i<4;i++) {
String temp=s+String.valueOf(i);
dfs(temp);
}
}
}
CSP201312_4
最新推荐文章于 2022-09-25 22:57:14 发布