A. Far Relative’s Birthday Cake

题目连接:

http://www.codeforces.com/contest/629/problem/A

Description

Door's family is going celebrate Famil Doors's birthday party. They love Famil Door so they are planning to make his birthday cake weird!

The cake is a n × n square consisting of equal squares with side length 1. Each square is either empty or consists of a single chocolate. They bought the cake and randomly started to put the chocolates on the cake. The value of Famil Door's happiness will be equal to the number of pairs of cells with chocolates that are in the same row or in the same column of the cake. Famil Doors's family is wondering what is the amount of happiness of Famil going to be?

Please, note that any pair can be counted no more than once, as two different cells can't share both the same row and the same column.

Input

In the first line of the input, you are given a single integer n (1 ≤ n ≤ 100) — the length of the side of the cake.

Then follow n lines, each containing n characters. Empty cells are denoted with '.', while cells that contain chocolates are denoted by 'C'.

Output

Print the value of Famil Door's happiness, i.e. the number of pairs of chocolate pieces that share the same row or the same column.

Sample Input

4
CC..
C..C
.CC.
.CC.

Sample Output

9

Hint

题意

给你一个n*n的矩阵,然后矩阵分钟的C会和在他同一行、同一列的C发生关系

然后问你一共发生多少次关系(嘿嘿嘿

题解:

水题啦

统计每一行有多少个,每一列有多少个,然后n*(n-1)/2就好了

代码

#include<bits/stdc++.h>
using namespace std;char s[120][120];int main()
{int n;scanf("%d",&n);for(int i=0;i<n;i++)scanf("%s",s[i]);int tot = 0;long long ans = 0;for(int i=0;i<n;i++){int tot = 0;for(int j=0;j<n;j++)if(s[i][j]=='C')tot++;ans += tot*(tot-1)/2;tot = 0;for(int j=0;j<n;j++)if(s[j][i]=='C')tot++;ans+=tot*(tot-1)/2;}cout<<ans<<endl;
}

Codeforces Round #343 (Div. 2) A. Far Relative’s Birthday Cake 水题相关推荐

  1. 【打CF,学算法——二星级】Codeforces Round #313 (Div. 2) B. Gerald is into Art(水题)...

    [CF简单介绍] 提交链接:http://codeforces.com/contest/560/problem/B 题面: B. Gerald is into Art time limit per t ...

  2. Codeforces Round #343 (Div. 2) D. Babaei and Birthday Cake 线段树维护dp

    D. Babaei and Birthday Cake 题目连接: http://www.codeforces.com/contest/629/problem/D Description As you ...

  3. VK Cup 2016 - Round 1 (Div. 2 Edition) A. Bear and Reverse Radewoosh 水题

    A. Bear and Reverse Radewoosh 题目连接: http://www.codeforces.com/contest/658/problem/A Description Lima ...

  4. Codeforces Round #740 (Div. 2, based on VK Cup 2021 - Final (Engine))

    Codeforces Round #740 (Div. 2, based on VK Cup 2021 - Final (Engine)) 题号 题目 知识点 A Simply Strange Sor ...

  5. Codeforces Round #597 (Div. 2) - BenFromHRBUST

    Codeforces Round #597 (Div. 2) -----比赛传送门----- A - Good ol' Numbers Coloring Problem Description Con ...

  6. Codeforces Round #470 (Div. 1)

    Contests 链接:Codeforces Round #470 (Div. 1) 过题数:3 排名:315/1183 A. Primal Sport 题意 AliceAliceAlice 和 Bo ...

  7. 【Christmas Game】【CodeCraft-21 and Codeforces Round #711 (Div. 2)】【Nim-博弈】【树形DP】【拆分树】

    CodeCraft-21 and Codeforces Round #711 (Div. 2) Christmas Game Nim-博弈 树形DP 拆分树 牛客链接 https://ac.nowco ...

  8. Codeforces Round #506 (Div. 3)

    Codeforces Round #506 (Div. 3) 实习期间事不多,对div3 面向题解和数据编程了一波 A. Many Equal Substrings 题目链接 A题就是找后缀和前缀重合 ...

  9. Codeforces Round #563 (Div. 2)/CF1174

    Codeforces Round #563 (Div. 2)/CF1174 CF1174A Ehab Fails to Be Thanos 其实就是要\(\sum\limits_{i=1}^n a_i ...

最新文章

  1. pyqtdeploy教程_PyQtdeploy-V2.4 User Guide 中文 (一)
  2. 乐鑫wifi模块二次开发_米家部分智能硬件拆解,ZigBee/WIFI模块分析及二次开发
  3. 华为云服务怎么弄金卡会员_万科牵手华为终端云服务,共建松山湖智慧商圈
  4. MFC中CString类字符串与长整型、浮点型、字符数组char数据之间的相互转换
  5. 多样人群,多面生活——观星盘八大策略人群洞察
  6. oracle apex 日志,oracle-apex - 在oracle apex报告中显示员工记录或经理记录及其员工 - SO中文参考 - www.soinside.com...
  7. IT人不要一直做技术(转载)
  8. D37 682. Baseball Game
  9. 第二层交换机工作原理
  10. 华为项目管理法10大模板【Excel和Word版(可直接套用)】
  11. 方方格子access_有哪些好用能提高工作效率的 Excel 插件(或 Office 办公插件)值得推荐?...
  12. weiPe系统启动盘还原
  13. Tips:PowerDesigner16.5 图表显示Code以及 Columns新增Commet显示
  14. node.js+uni计算机毕设项目计算机配件价格查询微信小程序(程序+小程序+LW)
  15. 【抓包】- Fiddle软件异常错误,Fiddler Failed to register Fiddler as the system proxy,解决方法
  16. Scratch精通之积木的使用
  17. 解读游戏“仙股”飞鱼科技年内涨幅超400%的逻辑
  18. 在项目中使用阿里巴巴矢量字体图标
  19. centos7 team 绑定
  20. 张一鸣和扎克伯格,一生之敌

热门文章

  1. 计算机网络主观论述题,《计算机网络》论述题
  2. python内置模块重要程度排名_python常用内置模块
  3. java随机整数_java如何产生1-8的整数随机数?
  4. android 图片放大缩小_贴在手机上的显微镜,轻松放大400倍,化身“蚁人”玩转微观世界...
  5. php中sql格式化字符串,sqli注入-sprintf格式化字符串带来的注入隐患
  6. vb用adodb链接mysql找不到_VB使用ADODB操作数据库的常用方法
  7. mysql 存储过程插入慢_mysql存储过程太慢怎么办
  8. Hadoop搭建集群中输入hdfs namenode -format格式化节点时,提示:hdfs: command not found 解决办法
  9. Jackson序列化实例
  10. Codeforces Round #326 (Div. 2) B. Pasha and Phone C. Duff and Weight Lifting