Fading Coder

One Final Commit for the Last Sprint

Home > Tech > Content

Determining Ride Compatibility Using Modular Arithmetic on Letter Products

Tech 1
#include <bits/stdc++.h>
using namespace std;

int main() {
    string comet, group;
    cin >> comet >> group;

    long product1 = 1, product2 = 1;

    for (char ch : comet) {
        product1 *= (ch - 'A' + 1);
    }

    for (char ch : group) {
        product2 *= (ch - 'A' + 1);
    }

    if ((product1 % 47) == (product2 % 47)) {
        cout << "GO" << endl;
    } else {
        cout << "STAY" << endl;
    }

    return 0;
}

Related Articles

Understanding Strong and Weak References in Java

Strong References Strong reference are the most prevalent type of object referencing in Java. When an object has a strong reference pointing to it, the garbage collector will not reclaim its memory. F...

Comprehensive Guide to SSTI Explained with Payload Bypass Techniques

Introduction Server-Side Template Injection (SSTI) is a vulnerability in web applications where user input is improper handled within the template engine and executed on the server. This exploit can r...

Implement Image Upload Functionality for Django Integrated TinyMCE Editor

Django’s Admin panel is highly user-friendly, and pairing it with TinyMCE, an effective rich text editor, simplifies content management significantly. Combining the two is particular useful for bloggi...

Leave a Comment

Anonymous

◎Feel free to join the discussion and share your thoughts.