标签:style blog http color io 2014
#include <stdio.h> #include <string.h> #include <algorithm> using namespace std; int t, n, m; char s[2]; int solve() { if (s[0] == ‘r‘) return min(n, m); if (s[0] == ‘k‘) { if (n == 1) return m; if (m == 1) return n; if (n == 2) return (m / 2 * 2 + m % 2 * 2); if (m == 2) return (n / 2 * 2 + n % 2 * 2); return (n * m + 1) / 2; } if (s[0] == ‘Q‘) return min(n, m); if (s[0] == ‘K‘) return (n + 1) / 2 * ((m + 1) / 2); } int main() { scanf("%d", &t); while (t--) { scanf("%s%d%d", s, &n, &m); printf("%d\n", solve()); } return 0; }
UVA 278 - Chess(数论),码迷,mamicode.com
标签:style blog http color io 2014
原文地址:http://blog.csdn.net/accelerator_/article/details/24633925