这道题是比较两个字符串根据A = 1,Z = 26这种关系来进行乘法运算得到的值a和b
Mod 47之后值的关系,相等输出“GO”,不相等输出“STAY”。
/* ID:yucept21 LANG:C++ TASK:ride */ #include#include #include int main() { freopen( "ride.in", "r", stdin); freopen( "ride.out", "w", stdout); char s1[6], s2[6]; long a = 1, b = 1; scanf( "%s%s", s1, s2); int len1 = strlen( s1); int len2 = strlen( s2); for( int i = 0; i < len1; i ++) a *= ( s1[i] - 'A' + 1); for( int i = 0; i < len2; i ++) b *= ( s2[i] - 'A' + 1); a %= 47; b %= 47; if( a == b) printf( "GO\n"); else printf( "STAY\n"); return 0; }