test

来源:互联网 发布:快易通中医处方软件 编辑:程序博客网 时间:2024/04/30 00:10
/*ID: Singles Xin[xl1993a1]LANG: JAVAPROG: crypt1 */import java.io.*;import java.util.*;public class crypt1 {private static int array[];public static void main(String[] args) throws IOException {// Use BufferedReader rather than RandomAccessFile; it's much fasterBufferedReader f = new BufferedReader(new FileReader("crypt1.in"));// input file name goes abovePrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("crypt1.out")));int n = Integer.parseInt(f.readLine());StringTokenizer st = new StringTokenizer(f.readLine());int count = 0;array = new int[n];for(int i = 0; i< n;i++){array[i] = Integer.parseInt(st.nextToken());}for(int i = 111; i<=9999/11;i++){if(check(i)){for(int j = 11;j <= ((999/i) * 11); j++){if(handle(i,j)&&(j%10 * i <=999)){count++;}}}}out.println(count);out.close(); // close the output fileSystem.exit(0); // don't omit this!}private static boolean handle(int num1, int num2){boolean result = true;if(check(num1) && check(num2) && check(num1 * num2)){while(num2 != 0){if(check(num1*(num2%10))){num2 = num2/10;}else{result = false;break;}}}else{result = false;}return result;}private static boolean check(int num){boolean result = true;while(num !=0){if(!isset(num%10)){result = false;break;}else{num = num /10;}}return result;}private static boolean isset(int num){boolean result = false;for(int i = 0; i<array.length;i++){if(array[i] == num){result = true;break;}}return result;}}

0 0