2013-java-A-省赛-2-振兴中华
2013-java-A-省赛-2-振兴中华
我的代码
public class Main {
static int ans;
static int[][] a= {
{1,2,3,4,5},
{2,3,4,5,6},
{3,4,5,6,7},
{4,5,6,7,8}
};
public static void main(String[] args) {
ans=0;
dfs(0,0,"");
System.out.println(ans);
}
/**
* @param i
* @param j
*/
private static void dfs(int i, int j, String s) {
s+=(""+a[i][j]);
if(s.equals("12345678")) {
ans++;
return;
}
共有 0 条评论