Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted by 678 ( 15 years ago )
import java.io.*;
public class Main{
    public static void main (String[] args) throws IOException{
        StreamTokenizer in = new StreamTokenizer (new BufferedReader (new InputStreamReader (System.in)));
        PrintWriter out = new PrintWriter (new OutputStreamWriter (System.out));

        in.nextToken(); int n=(int)in.nval;
        in.nextToken(); int m=(int)in.nval;
        int[][] data = new int[10][10];
        int max;

        data[m][n]=1;
        for (int i=m+1; i<=8; i++) {
            for (int j=1; j<=8; j++) {
                data[i][j] = data[i-1][j-1]+data[i-1][j+1];
            }
        }

        max=0;
        for (int i=1; i<=8; i++) max+=data[8][i];

        out.println (max);
        out.close();
    }
}

 

Revise this Paste

Parent: 11186
Your Name: Code Language: