1 solutions

  • 0
    @ 2025-11-5 18:42:16

    C :

    #include<stdio.h>
    
    int main()
    {
    	int starNum=1,teamNum=1;
    	char c;
    	int n;
    	while((c=getchar())!='\n')
    	{
    		n=c-64;
    		starNum*=n;
    		starNum=starNum%47;
    	}
    	while((c=getchar())!='\n')
    	{
    		n=c-64;
    		teamNum*=n;
    		teamNum=teamNum%47;
    	}
    	if(starNum==teamNum)
    		printf("GO\n");
    	else
    		printf("STAY\n");
    	return 0;
    }
    

    C++ :

    #include <algorithm>
    #include <cmath>
    #include <cstdio>
    #include <cstdlib>
    #include <cstring>
    #include <iomanip>
    #include <iostream>
    #include <string>
    using namespace std;
    int gl,hl,sum,summ,i,j,k;
    int a[7],b[7];
    string g,h;
    int main()
    {
    	cin>>h;
    	cin>>g;
    	gl=g.size();
    	hl=h.size();
    	sum=1;
    	summ=1;
    	for(i=1;i<=hl;i++)
    	{
    		a[i]=h[i-1]-'A'+1;
    		sum*=a[i];
    	}
    	for(i=1;i<=gl;i++)
    	{
    		b[i]=g[i-1]-'A'+1;
    		summ*=b[i];
    	}
    	j=sum%47;
    	k=summ%47;
    	if(j==k)
    	    cout<<"GO";
    	else
    	    cout<<"STAY";
    	return 0;
    }
    

    Pascal :

    program ride;
    var
      n1,n2:string;
      len1,len2,i,s1,s2:longint;
    begin
      readln(n1);
      readln(n2);
      len1:=length(n1);
      len2:=length(n2);
      s1:=1; s2:=1;
      for i:=1 to len1 do
        s1:=s1*(ord(n1[i])-64)mod 47;
      for i:=1 to len2 do
        s2:=s2*(ord(n2[i])-64)mod 47;
      if s1=s2 then writeln('GO')
        else writeln('STAY');
    end.
    
    
    • 1

    Information

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