首页 > 其他分享 >abc--275--C

abc--275--C

时间:2022-12-24 18:48:03浏览次数:62  
标签:10 abc -- int 275 x1

C - Counting Squares

//会重复,所以要除4
#include <bits/stdc++.h>
using namespace std;

char s[10][10];
bool check(int x,int y) {
    return x>=1&&y>=1&&x<=9&&y<=9&&s[x][y]=='#';
}


int main() {
    for(int i=1;i<=9;i++)
    for(int j=1;j<=9;j++)
        cin>>s[i][j];
    int ans=0;
    for(int x1=1;x1<=9;x1++)
    for(int y1=1;y1<=9;y1++)
    for(int x2=1;x2<=9;x2++)
    for(int y2=1;y2<=9;y2++) {
        if(x1==x2&&y1==y2)continue;
        if(s[x1][y1]=='.'||s[x2][y2]=='.')continue;
        int x3=x2-(y2-y1);
        int y3=y2-(x1-x2);
        int x4=x1-(y2-y1);
        int y4=y1-(x1-x2);
        if(check(x3,y3)&&check(x4,y4))ans++;
    }
    cout<<ans/4;
    return 0;
}

标签:10,abc,--,int,275,x1
From: https://www.cnblogs.com/basicecho/p/17003181.html

相关文章

  • 聚光灯
    <!DOCTYPEhtml><html><head><metacharset="utf-8"><title></title><linkrel="stylesheet"href="new_file.css"/></head>......
  • 马的移动
    小明很喜欢下国际象棋,一天,他拿着国际象棋中的“马”时突然想到一个问题:给定两个棋盘上的方格A和B,马从A跳到B最少需要多少步?现请你编程解决这个问题。提示:国际象棋棋盘为8......
  • 四、文件IO函数
    相关函数:open头文件 :#include<sys/types.h>           #include<sys/stat.h>           #include<fcntl.h>函数原型:intopen(constch......
  • 六、格式化输入输出和错误处理函数
    相关函数:printf头文件 :#include<stdio.h>函数原型:intprintf(constchar*format,…);函数说明:printf会根据参数format来转换并格式化数据,然后将结果写到标准输......
  • 标准IO函数
    相关函数:fopen头文件 :#include<stdio.h>函数原型:FILE*fopen(constchar*path, constchar*mode);函数说明:参数path字符串包含要打开的文件路径和文件名 ......
  • 文件和目录函数
    相关函数:stat头文件 :#include<sys/stat.h>           #include<unistd.h>函数原型:intstat(constchar*path,structstat*buf);函数说明:stat用......
  • 内存管理函数
    相关函数:malloc头文件 :#include<stdlib.h>函数原型:void*malloc(size_tsize);函数说明:分配内存返回值 :成功返回分配的内存的首地址           ......
  • 八、进程相关函数
    相关函数:abort头文件 :#include<stdlib.h>函数原型:voidabort(void);函数说明:引起进程异常终止,此时所有已打开的文件流会自动关闭,缓冲区里的数据也会自动写回返......
  • 嵌入式LinuxC语言开发工具
    C语言产生的历史背景嵌入式Linux下C语言的开发环境嵌入式Linux下的编辑器vi嵌入式Linux下的编译器GCC嵌入式Linux下的调试器GDB嵌入式Linux下的工程管理器makeEclipse集成......
  • Android studio学习第一期
    下载工具 Androidstudio参考博客https://blog.csdn.net/weixin_45406151/article/details/114531103汉化完成并创建了虚拟手机 安卓app项目目录结构模块编译规......