zoukankan      html  css  js  c++  java
  • Codeforces Round #343 (Div. 2) A. Far Relative’s Birthday Cake

    水题

     1 #include<iostream>
     2 #include<string>
     3 #include<algorithm>
     4 #include<cstdlib>
     5 #include<cstdio>
     6 #include<set>
     7 #include<map>
     8 #include<vector>
     9 #include<cstring>
    10 #include<stack>
    11 #include<cmath>
    12 #include<queue>
    13 #define clc(a,b) memset(a,b,sizeof(a))
    14 #include <bits/stdc++.h>
    15 using namespace std;
    16 #define LL long long
    17 
    18 int main()
    19 {
    20     char s[110][110];
    21     int n;
    22     scanf("%d",&n);
    23     for(int i=0;i<n;i++)
    24         scanf("%s",&s[i]);
    25     LL tot=0;
    26     LL ans=0;
    27     for(int i=0;i<n;i++)
    28     {
    29         tot=0;
    30         for(int j=0;j<n;j++)
    31         {
    32             if(s[i][j]=='C')
    33                 tot++;
    34         }
    35         ans+=tot*(tot-1)/2;
    36         tot=0;
    37         for(int j=0;j<n;j++)
    38         {
    39             if(s[j][i]=='C')
    40                 tot++;
    41         }
    42         ans+=tot*(tot-1)/2;
    43     }
    44     cout<<ans<<endl;
    45     return 0;
    46 }
    View Code
  • 相关阅读:
    一周内签到连续天数求解
    int型动态数组总结
    快速排序总结
    希尔排序总结
    冒泡排序的总结
    桶排序总结
    插入排序的总结
    选择排序的总结
    二分法的五种实现
    安装Yum源
  • 原文地址:https://www.cnblogs.com/ITUPC/p/5207493.html
Copyright © 2011-2022 走看看