Advertisement
adityagupta1089

01TILES

Oct 17th, 2014
259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.69 KB | None | 0 0
  1. /**
  2.  * Created by aditya on 17-10-2014.
  3.  */
  4. import java.io.BufferedInputStream;
  5. import java.util.Scanner;
  6. public class Main {
  7.     public static void main(String args[]){
  8.         Scanner scan = new Scanner(new BufferedInputStream(System.in));
  9.         int n=scan.nextInt();
  10.         scan.close();
  11.         System.out.println(ways(n));
  12.     }
  13.     public static int perm(int a,int b){
  14.         int perm_num=1;
  15.       for(int i=0;i<a-1;i++){
  16.           perm_num*=(a+b-i)/(a-i);
  17.       }
  18.         return perm_num;
  19.     }
  20.     public static int ways(int r){
  21.         int ways=0;
  22.         for(int a=r,b=0;a>=0;b+=1,a-=2){
  23.             ways+= (perm(a,b))%15746;
  24.         }
  25.         return ways;
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement