1 solutions

  • 0
    @ 2025-11-5 15:37:17

    C :

    #include<stdio.h>
    #include<string.h>
    int main()
    {
        char a[1000],b[1000];
        int i,l1,l2,x,y,p,q;
        while(scanf("%s%s",a,b)!=EOF)
        {
            x=1;
            y=1;
            l1=strlen(a);
            l2=strlen(b);
            for(i=0;i<l1;i++)
            {
                p=a[i]-64;
                x*=p;
            }
            for(i=0;i<l2;i++)
            {
                q=b[i]-64;
                y*=q;
            }
            if(x%47==y%47)
            printf("GO\n");
            else
            printf("STAY\n");
        }
        return 0;
    }
    

    C++ :

    
    #include <iostream>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <string>
     
    using namespace std;
     
    const
    	int MAXN = 1010;
    int
    	a[MAXN], b[MAXN], n1, n2;
    string
    	x,y;
     
    int main()
    {
    	//freopen("ride.in","r",stdin);
    //	freopen("ride.out","w",stdout);
     
    	while(cin >> x)
        {
    	cin >> y;
          char
    		ch;
    	int
    		i, ans1 = 1, ans2 = 1;
    	n1 = x.length();
    	n2 = y.length();
    	for (int i = 0; i <= n1-1; i++)
    		ans1 *= int(x[i]) - 64;
    	for (int i = 0; i <= n2-1; i++)
    		ans2 *= int(y[i]) - 64;
    	ans1 %= 47;
    	ans2 %= 47;
    	if (ans1 == ans2)
    		cout << "GO" << endl;
    	else
    		cout << "STAY" << endl;
        }
    	return 0;
    }
    
    • 1

    Information

    ID
    16966
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    (None)
    Tags
    # Submissions
    0
    Accepted
    0
    Uploaded By