计蒜客-Chessboard Dancing(思维题)

不要怕长题! 不要怕长题! 不要怕长题!

90%的长题都很简单。

这道题其实仔细想一下拿个纸画一下就可以了,感觉更多的是在考翻译。

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<math.h>
using namespace std;

int main() {
    int S;
    char ty[5];
    while(scanf("%d%s",&S,ty) != EOF){
        if(*ty == 'R' || *ty == 'B')
            printf("%d\n",S);
        else if(*ty == 'K')
            printf("%d\n",min(4,S*S));
        else
            printf("%d\n",(S<=2 ? 1 : 2));
    }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/a1097304791/article/details/82261920