SHARE
TWEET

Untitled

a guest Mar 18th, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.io.BufferedReader;
  2. import java.io.IOException;
  3. import java.io.InputStreamReader;
  4. import java.util.*;
  5.  
  6. public class Main {
  7.  
  8.  
  9.     public static void main(String[] args) throws IOException {
  10.  
  11.         List<String> coolNumbers = new ArrayList<>();
  12.         Set<String> coolNumbersSet = new HashSet<>();
  13.         char[] chars = {'A', 'B', 'E', 'K', 'M', 'H', 'O', 'P', 'C', 'T', 'Х', 'У'};
  14.         for (int i = 0; i < chars.length; i++) {
  15.             for (int j = 1; j < 10; j++) {
  16.                 char subChars = chars[i];
  17.                 String number = String.format("%s %d%d%d %s%s", subChars, j, j, j, subChars, subChars);
  18.                 coolNumbers.add(number);
  19.             }
  20.         }
  21.         for (String s : coolNumbers) {
  22.             for (int l = 0; l < 10; l++) {
  23.                 for (int k = 1; k < 10; k++) {
  24.                     String les = String.format(" %d%d%d", 1, l, k);
  25.                     coolNumbersSet.add(s + les);
  26.                 }
  27.             }
  28.         }
  29.         System.out.println(coolNumbersSet);
  30.         while (true) {
  31.             BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
  32.             String string = reader.readLine();
  33.             ReturnModel returnModel = checkNumber(coolNumbersSet, string);
  34.             System.out.printf("%b (%d)",returnModel.isContains(),returnModel.getTotal());
  35.         }
  36.     }
  37.  
  38.     /**
  39.      * Метод проверки
  40.      *
  41.      * @param string
  42.      * @return
  43.      */
  44.     private static ReturnModel checkNumber(Set<String> set, String string) {
  45.         ReturnModel returnModel = new ReturnModel();
  46.         returnModel.setStart(System.currentTimeMillis());
  47.         if (set.contains(string)) {
  48.             returnModel.setFinish(System.currentTimeMillis());
  49.             returnModel.setContains(true);
  50.         } else {
  51.             returnModel.setFinish(System.currentTimeMillis());
  52.             returnModel.setContains(false);
  53.         }
  54.         return returnModel;
  55.     }
  56.  
  57.  
  58. }
  59.  
  60. class ReturnModel {
  61.  
  62.     private long start;
  63.     private long finish;
  64.     private boolean isContains;
  65.     private long total;
  66.  
  67.     public long getTotal() {
  68.         return this.total;
  69.     }
  70.  
  71.     public void setFinish(long finish) {
  72.         this.finish = finish;
  73.         this.total = finish - start;
  74.     }
  75.  
  76.     public long getFinish() {
  77.         return finish;
  78.     }
  79.  
  80.     public void setStart(long start) {
  81.         this.start = start;
  82.     }
  83.  
  84.     public boolean isContains() {
  85.         return isContains;
  86.     }
  87.  
  88.     public void setContains(boolean contains) {
  89.         isContains = contains;
  90.     }
  91. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top