Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.File;
- import java.util.Scanner;
- import java.util.Arrays;
- import java.io.IOException;
- import java.util.Map;
- import java.util.HashMap;
- import java.util.ArrayList;
- import java.util.LinkedHashMap;
- public class problema1 {
- int l[],x[],g;
- //ArrayList<info>a;
- //ArrayList<ArrayList<Integer>> a=new ArrayList<ArrayList<Integer>>();
- int succ[],vmax2=-1,vmax3=-1;
- int i=1,n=1,t=0,m=0,v[],nr=0,w[],z[],a[];
- Scanner sc=new Scanner( new File("date.in"));
- problema1()throws IOException{ x=new int[100];}
- void citire()
- {
- n=sc.nextInt();
- }
- void prel_sol()
- {
- for(i=1;i<=n;i++)
- System.out.print(x[i]);
- System.out.println();
- }
- boolean valid(int r)
- {
- for(int j=1;j<=r-1;j++)
- if(x[j]==x[j+1]) return false;
- return true;
- }
- void back(int k)
- {
- if(k==n+1) prel_sol();
- else
- {
- for(int i=1;i<=n;i++)
- {
- x[k]=i;
- if(valid(k)) back(k+1);
- }
- }
- }
- public static void main(String[] args)throws IOException {
- problema1 p1=new problema1();
- p1.citire();System.out.println(p1.n);
- p1.back(1);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement