Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package BaiToanTamHau;
- import java.util.Scanner ;
- import java.io.FileInputStream;
- import java.io.FileNotFoundException;
- public class Whitevalentine
- {
- public static int []A = new int[100];
- public static int []B = new int[100];
- public static int n, tempt, th;
- public static boolean snt (int a )
- {
- int count =0;
- for(int i=2; i<= a/2; i++)
- {
- int k = a%i;
- if( k== 0) count ++;
- }
- if( count != 0) return false;
- else return true ;
- }
- public static void Try(int i)
- {
- B[i]= 1;
- tempt ++;
- for( int t= 0; t< n ; t++)
- {
- if(B[t]== 0 && snt(A[i]+A[t]))
- {
- if(tempt == n-1 && snt(A[0]+A[t]))
- {
- th++;
- }
- else
- {
- Try(t);
- }
- }
- }
- tempt --;
- B[i]=0;
- }
- public static void main(String[] args) throws FileNotFoundException
- {
- System.setIn(new FileInputStream ("C:\\Users\\Thien\\Desktop\\file run\\vongtay.txt"));
- Scanner mk = new Scanner( System.in);
- int test = mk.nextInt();
- for(int t=0 ;t<test ;t++)
- {
- n = mk.nextInt();
- for( int i=0 ;i<n; i++)
- {
- A[i]= mk.nextInt();
- }
- tempt = th =0;
- Try(0);
- System.out.print(th + "\n");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement