codeforces 183A Headquarters
2012-05-07 20:21
232 查看
上次比赛比较有趣的一道题目, 就做了这一题...
初看不好想,经过分析,就会发现其实就是让你求一个矩阵面积。
比如说 我定义 左上 右下就是 来增长 边, 定义 左下右上 来增长 宽, 上左下右 来增长 宽和边。
ans = l * h
View Code
初看不好想,经过分析,就会发现其实就是让你求一个矩阵面积。
比如说 我定义 左上 右下就是 来增长 边, 定义 左下右上 来增长 宽, 上左下右 来增长 宽和边。
ans = l * h
View Code
#include <iostream> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <algorithm> using namespace std; typedef __int64 LL; #define inf 10000000 #define N 20010 int main (){ LL n, num[5]; char str[5]; while (scanf ("%I64d", &n) != EOF) { memset(num, 0,sizeof(num)); for (LL i = 0; i < n; ++i) { scanf ("%s", str); if(strcmp (str, "UR")==0) num[1] ++; if(strcmp (str, "UL")==0) num[2] ++; if(strcmp (str, "DR")==0) num[4] ++; if(strcmp (str, "DL")==0) num[3] ++; if(strcmp (str, "ULDR")==0) num[0] ++; } LL len1, len2, ans; len1 = 1 + num[1] + num[3] +num[0]; len2 = 1 + num[2] + num[4] +num[0]; ans = len1 *len2; printf("%I64d\n", ans); } return 0; }
相关文章推荐
- Codeforces-273(div2) A. Initial Bet
- 【codeforces 165E】 - Compatible Numbers 【位运算】
- Codeforces 464A No to Palindromes!
- 【Codeforces Round #194 (Div. 1)】Codeforces 333E Summer Earnings
- Codeforces 14D Two Paths 树的直径
- CodeForces 75 C.Modified GCD(数论)
- CodeForces-379A-New Year Candles
- CodeForces 616A Comparing Two Long Integers
- CodeForces 698A——Vacations(动态规划)
- [Codeforces 557E] Ann and Half-Palindrome (Trie树+子串排序)
- CodeForces - 255B
- Codeforces Good Bye 2017
- codeforces 363B round211 div2 B. Fence
- codeforces 616E - Sum of Remainders
- 分解质因数之codeforces_588B
- Codeforces 735B Urbanization【水题】
- CodeForces - 589F Gourmet and Banquet
- CodeForces 124 B.Permutations(next_permutation)
- CodeForces 474 E. Pillars
- Codeforces 612D The Union of k-Segments