数学+字符串问题 水题 直接上代码~
AC代码:
1 #include<bits/stdc++.h> 2 using namespace std; 3 typedef long long ll; 4 typedef unsigned long long ull; 5 6 namespace io { 7 const int SIZE = 1e7 + 10; 8 char inbuff[SIZE]; 9 char *l, *r; 10 inline void init() { 11 l = inbuff; 12 r = inbuff + fread(inbuff, 1, SIZE, stdin); 13 } 14 inline char gc() { 15 if (l == r) init(); 16 return (l != r) ? *(l++) : EOF; 17 } 18 void read(int &x) { 19 x = 0; char ch = gc(); 20 while(!isdigit(ch)) ch = gc(); 21 while(isdigit(ch)) x = x * 10 + ch - ‘0‘, ch = gc(); 22 } 23 } using io::read; 24 25 int main(){ 26 char a[7], b[7]; 27 cin>>a>>b; 28 int sum1 = 1, sum2 = 1; 29 for (int i = 0; i < strlen(a); i++) 30 sum1 *= (a[i] - ‘A‘ + 1); 31 for (int i = 0; i < strlen(b); i++) 32 sum2 *= (b[i] - ‘A‘ + 1); 33 if (sum1 % 47 == sum2 % 47) 34 cout<<"GO"<<endl; 35 else cout<<"STAY"<<endl; 36 return 0; 37 }
原文地址:https://www.cnblogs.com/Misuchii/p/10909747.html
时间: 2024-10-10 00:33:16