Advertisement
mickypinata

PROG-T1009: Seven Segment

Sep 15th, 2021
649
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.49 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. typedef long long lli;
  5.  
  6. const int N = 10;
  7. const int PB = 1e9 + 7;
  8.  
  9. vector<string> ex[10];
  10. map<lli, char> mp;
  11. char str[N][3][3];
  12.  
  13. lli inpNumber(int len){
  14.     for(int i = 0; i < 3; ++i){
  15.         for(int j = 0; j < len; ++j){
  16.             for(int k = 0; k < 3; ++k){
  17.                 scanf("%c", &str[j][i][k]);
  18.             }
  19.             scanf("%*c");
  20.         }
  21.     }
  22.     string a;
  23.     for(int i = 0; i < len; ++i){
  24.         lli hsh = 0;
  25.         for(int j = 0; j < 3; ++j){
  26.             for(int k = 0; k < 3; ++k){
  27.                 hsh *= PB;
  28.                 hsh += str[i][j][k];
  29.             }
  30.         }
  31.         a += mp[hsh];
  32.     }
  33.     return stol(a);
  34. }
  35.  
  36. int main(){
  37.  
  38.     ex[0] = {" _ ", "| |", "|_|"};
  39.     ex[1] = {"   ", "  |", "  |"};
  40.     ex[2] = {" _ ", " _|", "|_ "};
  41.     ex[3] = {" _ ", " _|", " _|"};
  42.     ex[4] = {"   ", "|_|", "  |"};
  43.     ex[5] = {" _ ", "|_ ", " _|"};
  44.     ex[6] = {" _ ", "|_ ", "|_|"};
  45.     ex[7] = {" _ ", "  |", "  |"};
  46.     ex[8] = {" _ ", "|_|", "|_|"};
  47.     ex[9] = {" _ ", "|_|", " _|"};
  48.     for(int i = 0; i < 10; ++i){
  49.         lli hsh = 0;
  50.         for(int j = 0; j < 3; ++j){
  51.             for(int k = 0; k < 3; ++k){
  52.                 hsh *= PB;
  53.                 hsh += ex[i][j][k];
  54.             }
  55.         }
  56.         mp[hsh] = '0' + i;
  57.     }
  58.     int lenA, lenB;
  59.     scanf("%d%d%*c", &lenA, &lenB);
  60.     lli a = inpNumber(lenA);
  61.     lli b = inpNumber(lenB);
  62.     cout << a + b;
  63.  
  64.     return 0;
  65. }
  66.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement