UVA1641 - ASCII Area
2015-10-07 19:39
106 查看
其实思路很简单的。。一行一行的扫,在两个/ \之间的点就是黑色要求的
#include <iostream> #include <algorithm> #include <cstring> #include <cstdlib> #include <cstdio> #include <cmath> using namespace std; const int INF = ~0U >> 1; const int maxn = 100+5; int m, n; char str[maxn][maxn]; int main() { while(scanf("%d%d", &m, &n) != EOF) { int ans = 0; double cnt = 0; for(int i = 0; i < m; ++i) { scanf("%s", str[i]); for(int j = 0; j < n; ++j) if(str[i][j] == '/' || str[i][j] == '\\') cnt += 0.5; } for(int i = 0; i < m; ++i) { bool ok = false; for(int j = 0; j < n; ++j) { if(str[i][j] == '/' || str[i][j] == '\\') ok = !ok; if(ok && str[i][j] == '.') ++ans; } } cout << (double)ans + cnt << endl; } return 0; }
相关文章推荐
- NRF905模式切换问题
- hdu4044 GeoDefense
- 做自己想做的事
- Spark SQL 1.3.0 DataFrame介绍、使用
- jQuery Mobile基础02----jQuery Mobile Widgets-page(跳转效果
- 【转载】Spark SQL 1.3.0 DataFrame介绍、使用
- 01背包问题
- swift开发笔记10 - 通过drawRect自定义控件外观
- 哈佛图书馆自习室墙上的训言 (自勉)
- 自信做人,积极做事
- ocp-188
- Ubuntu root 密码忘记-恢复
- 第六周--项目3括号的匹配
- ocp-187
- 无所舍,必无所获
- Ubuntu的环境变量
- css选择器优先级
- ocp-186
- ocp-185
- ocp-184