|
|
вернуться в форумA methodical way to solve(definitely can be improved) using c++ #include <bits/stdc++.h> using namespace std; int main() { int n; cin>>n; while(n--){ string s; int a,b; cin>>s; a = s[0]-'a'+1; b = s[1]-'0'; a = min(a,9-a); b = min(b,9-b); if(a==b){ if(a==1) printf("2\n"); else if(a==2) printf("4\n"); else printf("8\n"); } else { if((a==1&&b==2)||(a==2&&b==1)) printf("3\n"); else if((a==1&&b>=3)||(a>=3&&b==1)) printf("4\n"); else if((a==2&&b>=3)||(a>=3&&b==2)) printf("6\n"); else if(a>2&&b>2)printf("8\n"); } } return 0; } |
|
|