poj 1656 Counting Black
来源:互联网 发布:青岛灭门案 知乎 编辑:程序博客网 时间:2024/04/26 00:57
http://poj.org/problem?id=1656
这道题的题目的数据范围是比较小的,所以直接就用暴力处理就可以了,没有必要用二维树状数组,然后要注意的是输入处应该是字符串比较好,因为输入
字符的话(用%s),可能就要处理回车,那样会很麻烦。
#include<stdio.h>#include<iostream>#include<string.h>using namespace std;int a[105][105]={0};int main(){ int x,y,L,T; char str[10]; scanf("%d",&T); while(T--) { int s=0; scanf("%s",str); scanf("%d %d %d",&x,&y,&L); if(str[0]=='W') { for(int i=x;i<=x+L-1;i++) for(int j=y;j<=y+L-1;j++) { a[i][j]=0; } } else if(str[0]=='B') { for(int i=x;i<=x+L-1;i++) for(int j=y;j<=y+L-1;j++) { a[i][j]=1; } } else { for(int i=x;i<=x+L-1;i++) for(int j=y;j<=y+L-1;j++) { if(a[i][j]==1) s=s+1; } printf("%d\n",s); } } system("pause"); return 0;}
- POJ 1656 Counting Black
- poj 1656 Counting Black
- POJ 1656 Counting Black
- poj 1656 Counting Black
- poj 1656 Counting Black
- poj 1656 Counting Black
- poj 1656 Counting Black
- poj 1656 Counting Black
- POJ 1656 Counting Black
- Poj 1656 Counting Black
- poj 1656 Counting Black 水题
- POJ-1656-Counting Black- 四分树
- POJ 1656 Counting Black(水~)
- poj-1656-Counting Black-(树状数组)
- POJ-1565-Counting Black
- PKU 1656 Counting black
- 1656:Counting Black
- POJ-1656 Counting Black (二维树状数组 入门题)
- 创业十诫之三:忽视成本预算
- LED驱动
- 创业十诫之二:投资不熟悉的行业
- Android FileObserver 文件监听器总结(Android 文件同步管理基础之一)
- google performance tools 2.0在ubuntu 12.04上死锁
- poj 1656 Counting Black
- Flex程序包装页面(wrapper)结构解析
- 黑马程序员 Java基础 07
- /proc/meminfo
- ListView中加入LinearLayout listview baseadapter 的filter
- backtrace on mips
- 雪
- POJ 2109 算数积累
- 函数----SetWindowPos