• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
slon
nit-acm
博客园    首页    新随笔    联系   管理    订阅  订阅

codeforces 183A Headquarters

上次比赛比较有趣的一道题目, 就做了这一题...

初看不好想,经过分析,就会发现其实就是让你求一个矩阵面积。

比如说 我定义 左上 右下就是 来增长 边, 定义  左下右上 来增长 宽, 上左下右 来增长 宽和边。

ans = l * h

View Code
 1 #include <iostream>
 2 #include <stdio.h>
 3 #include <stdlib.h>
 4 #include <string.h>
 5 #include <algorithm>
 6 using namespace std;
 7 typedef __int64 LL;
 8 #define inf 10000000
 9 #define N 20010
10 int main (){
11     LL n, num[5];
12     char str[5];
13     while (scanf ("%I64d", &n) != EOF) {
14         memset(num, 0,sizeof(num));
15         for (LL i = 0; i < n; ++i) {
16             scanf ("%s", str);
17             if(strcmp (str, "UR")==0) num[1] ++;
18             if(strcmp (str, "UL")==0) num[2] ++;
19             if(strcmp (str, "DR")==0) num[4] ++;
20             if(strcmp (str, "DL")==0) num[3] ++;
21             if(strcmp (str, "ULDR")==0) num[0] ++;
22         }
23         LL len1, len2, ans;
24         len1 = 1 + num[1] + num[3] +num[0];
25         len2 = 1 + num[2] + num[4] +num[0];
26         ans = len1 *len2;
27         printf("%I64d\n", ans);
28 
29     }
30     return 0;
31 }
posted @ 2012-05-07 20:21  slon  阅读(327)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3