710A - King Moves - CodeForces Solution


implementation *800

Please click on ads to support us..

Python Code:

a,b=*input(),
x=a in'ah'
y=b in'18'
print(8-x*3-y*3+x*y)

C++ Code:

#include <iostream>
#include <algorithm>
#include <fstream>
using namespace std;

int n,x, e,  d, k, j, h, w, f, r, t, l, o, p, i1, i2,y;
char c[10000];
int main()
{
    //ifstream cin("input.txt");
    //ofstream cout("output.txt");
    cin >> c;
    if((c[0]=='a' or c[0]=='h') and (c[1]=='1' or c[1]=='8')) cout<<"3";
    if((c[0]=='a' or c[0]=='h') and (c[1]!='1' and c[1]!='8')) cout<<"5";
    if((c[0]!='a' and c[0]!='h') and (c[1]=='1' or c[1]=='8')) cout<<"5";
    if((c[0]!='a' and c[0]!='h') and (c[1]!='1' and c[1]!='8')) cout<<"8";
    return 0;
}


Comments

Submit
0 Comments
More Questions

555B - Case of Fugitive
551A - GukiZ and Contest
1399F - Yet Another Segments Subset
1371C - A Cookie for You
430B - Balls Game
1263A - Sweet Problem
1332B - Composite Coloring
254A - Cards with Numbers
215A - Bicycle Chain
1288B - Yet Another Meme Problem
1201C - Maximum Median
435A - Queue on Bus Stop
1409B - Minimum Product
723B - Text Document Analysis
1471C - Strange Birthday Party
1199A - City Day
1334A - Level Statistics
67B - Restoration of the Permutation
1734A - Select Three Sticks
1734B - Bright Nice Brilliant
357B - Flag Day
937A - Olympiad
1075A - The King's Race
1734C - Removing Smallest Multiples
1004C - Sonya and Robots
922A - Cloning Toys
817A - Treasure Hunt
1136B - Nastya Is Playing Computer Games
1388A - Captain Flint and Crew Recruitment
592B - The Monster and the Squirrel