Advertisement
mickypinata

USACO-T001: Your Ride is Here

Sep 19th, 2021
885
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.72 KB | None | 0 0
  1. /*
  2. ID: mickyta1
  3. TASK: ride
  4. LANG: C++
  5. */
  6.  
  7. #include <bits/stdc++.h>
  8. using namespace std;
  9.  
  10. const int N = 6;
  11. const int MD = 47;
  12.  
  13. char strA[N + 1], strB[N + 1];
  14.  
  15. int main(){
  16.  
  17.     freopen("ride.in", "r", stdin);
  18.     freopen("ride.out", "w", stdout);
  19.  
  20.     scanf(" %s %s", strA, strB);
  21.     int lenA = strlen(strA);
  22.     int proA = 1;
  23.     for(int i = 0; i < lenA; ++i){
  24.         proA = proA * (strA[i] - 'A' + 1) % MD;
  25.     }
  26.     int lenB = strlen(strB);
  27.     int proB = 1;
  28.     for(int i = 0; i < lenB; ++i){
  29.         proB = proB * (strB[i] - 'A' + 1) % MD;
  30.     }
  31.     if(proA == proB){
  32.         cout << "GO\n";
  33.     } else {
  34.         cout << "STAY\n";
  35.     }
  36.  
  37.     fclose(stdin);
  38.     fclose(stdout);
  39.  
  40.     return 0;
  41. }
  42.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement