monkeyslut45

Untitled

Mar 20th, 2019
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.76 KB | None | 0 0
  1. package com.company;
  2.  
  3. import java.io.FileNotFoundException;
  4. import java.io.FileReader;
  5. import java.util.Scanner;
  6.  
  7. public class Main {
  8. public static void main(String[] args) throws FileNotFoundException {
  9. Scanner in = new Scanner(new FileReader("input.txt"));
  10.  
  11. String str1 = in.next();
  12. String str2 = in.next();
  13.  
  14. in.close();
  15.  
  16. int n = 0;
  17. n = str1.length();
  18.  
  19. int res = 4;
  20.  
  21. boolean all = true;
  22. for(int i = 0; i < n; i++){
  23. if(str1.charAt(i) != '?'){
  24. all = false;
  25. }
  26. if(str2.charAt(i) != '?'){
  27. all = false;
  28. }
  29. }
  30.  
  31. int k1=0, k2=0;
  32. for(int i = 0; i < n; i++){
  33. char cur1 = str1.charAt(i);
  34. char cur2 = str2.charAt(i);
  35. char a[] = new char[4];
  36. char b[] = new char[4];
  37.  
  38. if(cur1 == '?' || cur2 == '?')
  39. res = res;
  40. else {
  41. if((cur1 >= 'a' && cur1 <= 'g')
  42. || (cur2 >= 'a' && cur2 <= 'g')){
  43. if(cur1 >= 'a' && cur1 <= 'g'){
  44. k1 = 4;
  45. }
  46. if(cur2 >= 'a' && cur2 <= 'g'){
  47. k2 = 4;
  48. }
  49. }
  50. if((cur1 >= '0' && cur1 <= '9')
  51. || (cur2 >= '0' && cur2 <= '9')){
  52. if(cur1 >= '0' && cur1 <= '9') {
  53. k1 = 1;
  54. }
  55. if(cur2 >= '0' && cur2 <= '9'){
  56. k2 = 1;
  57. }
  58. }
  59.  
  60. if(k1 == k2){
  61. if(k1 == 1) {
  62. if (cur1 != cur2)
  63. res = 0;
  64. else
  65. res = 1;
  66. }
  67. } else {
  68. if(k1 == 1){
  69. if(!(cur1 > (char)(cur2-49) && cur1 < (char)(cur2-46))){
  70. res = 0;
  71. return;
  72. }
  73. } else {
  74. if(!(cur2 > (char)(cur1-49) && cur2 < (char)(cur1-46))){
  75. res = 0;
  76. return;
  77. }
  78. else
  79. res = 1;
  80. }
  81. }
  82. }
  83. }
  84. if(all) System.out.println(9);
  85. else System.out.println(res);
  86. }
  87.  
  88. private static int min(int a, int b) {
  89. if(b == 0)
  90. return 0;
  91. else
  92. if(b > a)
  93. return b;
  94. else
  95. return a;
  96. }
  97.  
  98. private static int is(int a, int b, int last) {
  99. if(Math.abs(a-b)>3)
  100. return 0;
  101. else
  102. if(last > 4-Math.abs(a-b))
  103. return 4-Math.abs(a-b);
  104. else
  105. return last;
  106. }
  107. }
Add Comment
Please, Sign In to add comment