FZU 2064(暴力求解)
来源:互联网 发布:mac怎么找到安装目录 编辑:程序博客网 时间:2024/05/17 00:10
解析:我刚刚开始把这题给想复杂了,用回溯来求解,其实这题没有这么复杂,直接用两次for在加上判断是否越界,就可以解决了。
#include <cstdio>#include <cstring>#include <cstdlib>using namespace std;const int N = 200;int m,n,w;int grid[N][N];bool judge(int r,int c) {for(int i = 0; i < w; i++) {if(grid[r][c+i]) {return false;}}return true;}int main() {int t;scanf("%d",&t);while(t--) {memset(grid,0,sizeof(grid));scanf("%d%d%d",&n,&m,&w);for(int i = 0; i < n; i++) {for(int j = 0; j < m; j++) {scanf("%d",&grid[i][j]);}}int ans = 0;for(int i = 0; i < n; i++) {for(int j = 0; j < m; j++) {if( j + w <= m && judge(i,j)) {ans++;}}}printf("%d\n",ans);}return 0;}
0 0
- FZU 2064(暴力求解)
- fzu 2064(暴力)
- rectangle(暴力求解)
- hdoj1395(暴力求解)
- poj 2739(暴力求解)
- fzu 2148 Moon Game(暴力+几何)
- FZU 2148 Moon Game(暴力+几何)
- FZU - 2035 Axial symmetry(几何+暴力)
- FZU - 2148 Moon Game(暴力)
- FZU 2150 Fire Game (暴力BFS)
- FZU 2191完美的数字 (暴力)
- FZU 2206 函数求解(找规律)
- 暴力求解
- 暴力求解
- FZU 2041 暴力枚举
- fzu 2056 暴力
- hdu2069Coin Change(暴力求解----动态规划(背包)求解---搜索--)
- 494. Target Sum(暴力求解和二项式求解)
- NYOJ-九的余数
- -
- 深入分析Linux内核源码——6.3 内存的分配和回收
- .NET程序的代码混淆、加壳与脱壳
- 【LeetCode with Python】 Remove Duplicates from Sorted List II
- FZU 2064(暴力求解)
- Cocos2d-x 3.0 开发(四)使用CocoStudio创建UI并载入到程序中
- Codeforces Round #245 (Div. 1)B 递推DP
- 继承于CCObject而非CCLayer的界面的显示
- 【LeetCode with Python】 Remove Duplicates from Sorted Array II
- WPF/Silverlight深度解决方案:(二)Silverlight源码之自我保护(加密)
- android自带zip轻松实现压缩解压
- 7.27派生类的析构函数
- POJ3083 Children of the Candy Corn(BFS+DFS水题)