1 条题解

  • 0
    @ 2025-9-10 9:12:42

    C++ :

    /*
    ID: cjh-1143
    PROG: ride
    LANG: C++
    */
    #include<stdio.h>
    #include<string.h>
    int main(){
    //	freopen("ride.in","r",stdin);
    //	freopen("ride.out","w",stdout);
    	char s1[10], s2[10];
    	int i, x, t;
    	while(scanf("%s%s", s1, s2) != EOF){
    		for(x = 1, i = 0; s1[i]; i++)
    			x *= (s1[i]-'A'+1);
    		t = x%47;
    		for(x = 1, i = 0; s2[i]; i++)
    			x *= (s2[i]-'A'+1);
    		if(t == x%47) printf("GO\n");
    		else printf("STAY\n");
    	}
        return 0;
    }
    /*
    ------- test 1 ----
    COMETQ
    HVNGAT
    ------- test 2 ----
    STARAB
    USACO
    ------- test 3 ----
    EARTH
    LEFTB
    ------- test 4 ----
    PULSAR
    VENUS
    ------- test 5 ----
    KANSAS
    UTAH
    ------- test 6 ----
    APPLE
    URSA
    ------- test 7 ----
    MSFT
    MARS
    ------- test 8 ----
    PLUTO
    BKHOLE
    ------- test 9 ----
    COWSBC
    RIGHT
    ------- test 10 ----
    DRKMTR
    SNIKER
    */
    

    Pascal :

    var s1,s2:string;s3:char;
    a1,a2,i:longint;
    begin
      a1:=1;
      a2:=1;
      readln(s1);
      readln(s2);
      FOR i:=1 to length(s1) do
       a1:=(ord(s1[i])-64)*a1;
      FOR i:=1 to length(s2) do
       a2:=(ord(s2[i])-64)*a2;
      if (a1 mod 47)=(a2 mod 47) then
      writeln('GO')
      else  WRITELN('STAY');
    end.
    
    
    • 1

    信息

    ID
    4207
    时间
    1000ms
    内存
    128MiB
    难度
    (无)
    标签
    递交数
    0
    已通过
    0
    上传者