summaryrefslogtreecommitdiff
path: root/278/chess.cpp
diff options
context:
space:
mode:
authorAditya Naik2018-10-09 00:00:20 -0400
committerAditya Naik2018-10-09 00:00:20 -0400
commit01ab905a0603b4fe35bf438bec39d48f3ad61fe2 (patch)
tree9f7df2a13cec94568488e0ee24b89a33bb544298 /278/chess.cpp
parent2679beaa560d1b51afb40ad5d813b38cff45f19c (diff)
278 AC
Diffstat (limited to '278/chess.cpp')
-rw-r--r--278/chess.cpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/278/chess.cpp b/278/chess.cpp
new file mode 100644
index 0000000..a6bd14b
--- /dev/null
+++ b/278/chess.cpp
@@ -0,0 +1,43 @@
+#include <iostream>
+
+int ceil(float a){
+ float dec = a - (int)a;
+ if(dec>0)
+ return (int)a+1;
+ return (int)a;
+}
+
+int main(){
+ int n, r, c, bignum, smallnum;
+ char p;
+ std::cin>>n;
+ while(n--){
+ std::cin>>p>>r>>c;
+ if(r > c){
+ bignum = r;
+ smallnum = c;
+ }
+ else{
+ bignum = c;
+ smallnum = r;
+ }
+
+
+ switch(p){
+ case 'r':
+ std::cout<<smallnum<<std::endl;
+ break;
+ case 'K':
+ std::cout<<ceil((float)smallnum/2)*ceil((float)bignum/2)
+ <<std::endl;
+ break;
+ case 'k':
+ std::cout<<(smallnum*ceil((float)bignum/2)-
+ (bignum%2==0 ? 0 : (int)smallnum/2))<<std::endl;
+ break;
+ case 'Q':
+ std::cout<<smallnum<<std::endl;
+ break;
+ }
+ }
+}