prompt
string
response
string
Problem: 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 ...
import java.util.Scanner; import java.lang.Math; public class Ishu { public static void main(String[] args) { Scanner scan=new Scanner(System.in); int n,i,j,k,sum=0; String[] cake=new String[100]; char[][] ch=new char[100][100]; n=scan.nextInt(); for(i=0;i<n;++i) { cake[i]=...
Problem: 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 ...
import java.io.*; import java.util.*; import java.math.*; import static java.lang.Math.*; import static java.lang.Integer.parseInt; import static java.lang.Long.parseLong; import static java.lang.Double.parseDouble; import static java.lang.String.*; public class Main { public static void main(String[] args) t...
Problem: 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 ...
#include <bits/stdc++.h> using namespace std; int main() { int n, m, i, j, p, q, cnt, k, cnt1; char s[105][105], ch; while (cin >> n) { getchar(); p = 0; for (i = 1; i <= n; i++) { for (j = 1; j <= n; j++) { cin >> ch; s[i][j] = ch; } } for (i = 1; i <= n; i++) { ...
Problem: 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 ...
#include <bits/stdc++.h> using namespace std; char a[1001][1001]; int s, sum; int main() { int i, j, n; cin >> n; for (i = 1; i <= n; i++) for (j = 1; j <= n; j++) cin >> a[i][j]; for (i = 1; i <= n; i++) { for (j = 1; j <= n; j++) { if (a[i][j] == 'C') s++; } sum += (s * (s - 1) / 2); ...
Problem: 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 ...
n = int(input()) arr = [list(input()) for i in range(n)] ans = 0 for i in arr: s = 0 for j in i: if(j == 'C'): s+=1 ans += (s * (s-1))//2 for i in range(n): s = 0 for j in range(n): if(arr[j][i] == 'C'): s+=1 ans += (s * (s -1 ))//2 print(ans)
Problem: 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 ...
size = int(input()) m = [] h = 0 for i in range(size): line = input() c = line.count("C") h+=(c*(c-1))/2 m.append(line) for i in range(size): C = 0 for j in range(size): if m[j][i]=="C": C+=1 h+=(C*(C-1))/2 print(int(h))
Problem: 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 ...
#include <bits/stdc++.h> const int MAXN = 100; char cake[MAXN][MAXN + 1]; int main() { int n; scanf("%d", &n); for (int row = 0; row < n; ++row) { scanf("%s", cake[row]); } int pairs = 0; for (int i = 0; i < n; ++i) { int inRow = 0, inCol = 0; for (int j = 0; j < n; ++j) { inRow += cake[i]...
Problem: 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 ...
#include <bits/stdc++.h> using namespace std; const int N = 100; char s[N][N]; int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%s", s[i]); int ans = 0; for (int i = 0; i < n; i++) { int cnt1 = 0, cnt2 = 0; for (int j = 0; j < n; j++) { if (s[i][j] == 'C') cnt1++; if...
Problem: 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 ...
#include <bits/stdc++.h> using namespace std; int main() { int n; scanf("%d", &n); vector<int> C(n), R(n); char c[200]; for (int i = 0; i < n; i++) { scanf("%s", c); for (int j = 0; j < n; j++) if (c[j] == 'C') { C[j]++; R[i]++; } } int ans = 0; for (int i = 0; i < n;...
Problem: 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 ...
import java.util.*; import java.io.*; public class cake{ public static void main(String[] args) throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out)); int n = in(br.readLine()); char[][] map = new ...
Problem: 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 ...
n = int(input()) data = [input() for i in range(n)] answer = 0 for i in range(n): help = 0 for j in range(n): if data[i][j] == "C": help += 1 answer += help * (help - 1) // 2 for i in range(n): help = 0 for j in range(n): if data[j][i] == "C": help += 1 an...
Problem: 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 ...
import java.io.*; import java.util.*; public class solution { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); ArrayList<String>A = new ArrayList<>(); for(in...
Problem: 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 ...
#include <bits/stdc++.h> using namespace std; const int N = 1e5; const int mod = 1e9 + 7; const int eps = 1e9 - 11; const int inf = 2e9; long long n, ans; long long st[N], sr[N]; char c; int main() { cin >> n; for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { cin >> c; if (c == 'C') st[i...
Problem: 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 ...
#include <bits/stdc++.h> using namespace std; int C(int n) { return n * (n - 1) / 2; } int main() { ios::sync_with_stdio(false); int n; cin >> n; vector<vector<char> > v(n, vector<char>(n)); for (int i = 0; i < (int)n; i++) for (int j = 0; j < (int)n; j++) { cin >> v[i][j]; } vector<int> x(n, ...
Problem: 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 ...
#include <bits/stdc++.h> using namespace std; int a[101], b[101]; long long dat[1001]; long long modex(long long x) {} int main() { int n; dat[2] = 1; cin >> n; for (int i = 3; i <= n; i++) { dat[i] = dat[i - 1] + i - 1; } for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { char dum;...
Problem: 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 ...
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; public class A { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter out = new Print...
Problem: 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 ...
#include <bits/stdc++.h> using namespace std; int fact(int n); int main() { int n; int row[100]; int column[100]; for (int i = 0; i < 100; i++) { row[i] = 0; column[i] = 0; } cin >> n; char tmp_row[101] = ""; for (int i = 0; i < n; i++) { cin >> tmp_row; for (int j = 0; j < n; j++) { ...
Problem: 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 ...
n = int(input()) rows = [0] * n cols = [0] * n def fact(num): res = 1 while num > 1: res *= num num -= 1 return res def nC2(count): if count < 2: return 0 elif count == 2: return 1 return fact(count)//(2*fact(count-2)) for row in range(n): for col, ch in e...
Problem: 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 ...
import java.util.Scanner; public class Farrelativebirthdaycake { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Scanner input = new Scanner(System.in); int n = input.nextInt(); String[] s = new String[n]; for(int i=0;i<n;i++)s[i] = input.next(); in...
Problem: 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 ...
#include <bits/stdc++.h> using namespace std; struct vertex { int x, y; }; int main() { int n; cin >> n; vector<string> v(n); map<int, int> m, l; for (int i = 0; i < n; i++) { cin >> v[i]; for (int j = 0; j < n; j++) { if (v[i][j] == 'C') { m[i]++; l[j]++; } } } i...
Problem: 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 ...
#include <bits/stdc++.h> using namespace std; int main() { int n; char str[105][105]; while (scanf("%d", &n) != EOF) { for (int i = 0; i < n; i++) { scanf("%s", str[i]); } int ans = 0, cnt; for (int i = 0; i < n; i++) { cnt = 0; for (int j = 0; j < n; j++) if (str[i][j] =...
Problem: 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 ...
import collections import math #n, m = map(int, input().split()) n = int(input()) t = [input() for _ in range(n)] ans = 0 for i in range(n): x = t[i].count('C') #print(x) if x >= 2: ans += (x - 1) * x // 2 #print(ans) for i in range(n): temp = 0 for j in range(n): if t[j][i] == 'C'...
Problem: 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 ...
#include <bits/stdc++.h> using namespace std; int N, row[105], col[105]; string mp[105]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); ; cin >> N; for (int i = 0; i < (N); i++) { cin >> mp[i]; for (int j = 0; j < (N); j++) { if (mp[i][j] == 'C') { row[i]++; col[j]++; ...
Problem: 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 ...
#include <bits/stdc++.h> using namespace std; int n, a[105], b[105], ans; char c; int main() { cin >> n; for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) { cin >> c; if (c == 'C') ans += ((a[j]++) + (b[i]++)); } cout << ans << "\n"; exit(0); }
Problem: 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 ...
#!/usr/bin/python # -*-coding:utf-8 -*- import itertools from collections import Counter def f(a): value=0 if 'C'in a: value=(a['C'])*(a['C']-1)/2 return value n=int(raw_input()) cake=[[0 for i in range(n)]for j in range(n)] for i in range(n): cake[i]=list(raw_input()) count=0 for i in range(n):...
Problem: 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 ...
#include <bits/stdc++.h> using namespace std; int n, i, j, ans, cnt, cnt2; char s[110][110]; int main() { scanf("%d", &n); for (i = 1; i <= n; i++) scanf("%s", s[i] + 1); for (i = 1; i <= n; i++) { cnt = cnt2 = 0; for (j = 1; j <= n; j++) cnt += s[i][j] == 'C', cnt2 += s[j][i] == 'C'; ans += (cnt * (c...
Problem: 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 ...
#include <bits/stdc++.h> using namespace std; long long a[1000], b[1000]; int main() { long long n; cin >> n; char x; long long ans = 0; for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { cin >> x; if (x == 'C') { a[i]++; b[j]++; } } } for (int i = 1; i...
Problem: 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 ...
#include <bits/stdc++.h> using namespace std; int n; vector<string> polje; int main() { cin >> n; polje.resize(n); int sol = 0; for (int i = 0; i < n; ++i) { cin >> polje[i]; for (int j = 0; j < n; ++j) { if (polje[i][j] == 'C') { for (int k = j + 1; k < n; ++k) { if (polje[i][k]...
Problem: 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 ...
# Far Relative’s Birthday Cake - codeforces # import math import sys input = sys.stdin.readline # k taken n combination # n!/k!(n-k)! def inp(): return int(input()) def insr(): s = input() return list(s[:len(s) - 1]) def pair(n): return math.factorial(n) / (2 * math.factorial(n - 2)) n = inp()...
Problem: 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 ...
#include <bits/stdc++.h> using namespace std; char arr[105][105]; int n, res; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> arr[i]; } for (int x = 0; x < n; x++) { for (int y1 = 0; y1 < n; y1++) { for (int y2 = y1 + 1; y2 < n; y2++) { if (arr[x][y1] == 'C' && arr[x][y2] == 'C...
Problem: 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 ...
n = int(input()) arr = ["" for i in range(n)] cnt = 0 for i in range(n): s = input() for j in range(n): arr[j] += s[j] a = s.count("C") b = [i for i in range(1, a)] cnt += sum(b) for i in arr: a = i.count("C") b = [i for i in range(1, a)] cnt += sum(b) print(cnt)
Problem: 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 ...
// package greedy; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class FarRelativeBirthdayCake { public static void main(String[] args) throws NumberFormatException, IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int ...
Problem: 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 ...
#include <bits/stdc++.h> using namespace std; int factor(int x) { int f = 0; for (int i = 1; i < x; i++) { f = f + (x - i); } return f; } int main() { int n, t = 0, R = 0, f; cin >> n; char arr[n][n]; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) cin >> arr[i][j]; } for (int i = ...
Problem: 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 ...
#-------------Program-------------- #----Kuzlyaev-Nikita-Codeforces---- #-------------Training------------- #---------------------------------- n=int(input()) a=[];r=0;v=[] for i in range(n):v.append([]) for i in range(n): f=list(str(input())) a.append(f) for j in range(n): v[j].append(f[j]) for i ...
Problem: 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 ...
import math n = int(input()) c = [] for i in range(n): s = input() c.append(s) l = 0 for i in range(len(c)): if c[i].count('C')>=1: k = c[i].count('C') l+=(k*(k-1))//2 d = {} for i in range(n+1): d[i] = 0 for i in range(len(c)): for j in range(len(c[i])): if c[i][j]=='C': ...
Problem: 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 ...
import java.util.Scanner; public class Main { public static void main(String[] args){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); String[] cake = new String[n]; for(int i=0;i<n;i++){ cake[i] = sc.next(); } long sum = 0; for(int i=0;i<n;i++){ int count = 0; for(int j=0;j<n;j++){ ...
Problem: 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 ...
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.InputStreamReader; import java.io.OutputStreamWriter; public class NewClass1 { public static void main(String[] args) throws Exception { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); BufferedWri...
Problem: 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 ...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; char arr[n][n]; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { cin >> arr[i][j]; } } vector<int> v; for (int i = 0; i < n; i++) { short counter = 0; short counter1 = 0; for (int j = 0; j < n;...
Problem: 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 ...
#include <bits/stdc++.h> using namespace std; char s[105][105]; int n, m, ans; int main() { scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%s", s[i] + 1); int tot = 0; for (int j = 1; j <= n; j++) if (s[i][j] == 'C') tot++; if (tot > 1) ans += (tot - 1) * tot / 2; } for (int j = 1;...
Problem: 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 ...
#include <bits/stdc++.h> using namespace std; long long factorial[105]; long long rows[105]; long long columns[105]; char m[105][105]; long long fat(long long n) { if (factorial[n] != 0) { return factorial[n]; } if (n <= 1) { return factorial[n] = 1; } return factorial[n] = n * fat(n - 1); } long long...
Problem: 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 ...
def fat(n): res = 1 for i in range(2,n+1): res *= i return res def comb(n): if n<2: return 0 return fat(n)//(fat(n-2)*2) n = int(input()) mat = [] for i in range(n): mat.append(input()) contLinha = 0 contColuna = 0 soma = 0 for i in range(n): contLinha = 0 contColuna...
Problem: 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 ...
// John Lewis // Date: // Program: import java.util.*; import java.io.*; public class Main { public static void main(String[] args) throws IOException { input.init(System.in); PrintWriter out = new PrintWriter(System.out); // Variables int n = input.nextInt(); int[] countRow = new int...
Problem: 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 ...
n = int(input()) s= '' ans = 0 for i in range(n): temp = str(input()) s = s+temp x =temp.count('C') if x>1: ans = ans + (x* (x-1))//2 i = 0 while i<n: j = i temp = '' while j<len(s): temp = temp + s[j] j= j+ n x =temp.count('C') if x>1: ans = ans + (x*...
Problem: 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 ...
#include <bits/stdc++.h> using namespace std; long long revNumber(long long n) { long long b = 0; while (n != 0) { b = b * 10 + n % 10; n /= 10; } return b; } long long leapYearCheck(long long year) { if (year % 4 != 0) return 0; else if (year % 100 != 0) return 1; else if (year % 400 != 0...
Problem: 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 ...
n = int(raw_input()) b = [raw_input().strip() for _ in xrange(n)] ans = 0 for r in b + zip(*b): k = r.count('C') ans += k * (k - 1) / 2 print ans
Problem: 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 ...
#include <bits/stdc++.h> int fact(int); int main() { int n; scanf("%d", &n); char o[n][n]; for (int i = 0; i < n; i++) { scanf("%s", &o[i]); } int r[n], c[n]; for (int i = 0; i < n; i++) { r[i] = 0; c[i] = 0; for (int j = 0; j < n; j++) { if (o[i][j] == 'C') { r[i]++; }...
Problem: 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 ...
#include <bits/stdc++.h> using namespace std; int read() { int res = 0, w = 1; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') w = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') { res = (res << 3) + (res << 1) + ch - '0'; ch = getchar(); } return res * w; } void wr...
Problem: 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 ...
n=int(input()) r=[0 for i in range(n)] c=[0 for i in range(n)] for i in range(n): s=str(input()) for j in range(n): if s[j]=='C': r[i]+=1 c[j]+=1 an=0 for i in r: an+=i*(i-1)//2 for i in c: an+=i*(i-1)//2 print(an)
Problem: 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 ...
#include <bits/stdc++.h> using namespace std; const int INF = 1e9 + 7; char a[100][100]; long long ans; long long ncr(int n, int r) { long long ans = 1; r = min(r, n - r); n++; for (int f = 1; f <= r; f++) { ans *= n - f; ans /= f; } return ans; } int main() { ios::sync_with_stdio(false); int n,...
Problem: 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 ...
#include <bits/stdc++.h> using namespace std; template <class X, class Y> void minimize(X &x, const Y &y) { if (x > y) x = y; } template <class X, class Y> void maximize(X &x, const Y &y) { if (x < y) x = y; } char a[111][111]; int n; void process(void) { scanf("%d", &n); for (int i = (1), _b = (n); i <= _b; i ...
Problem: 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 ...
#include <bits/stdc++.h> using namespace std; string s[105]; int row[150], col[150], sum = 0; int main() { int n; cin >> n; for (int i = 1; i <= n; i++) { string x; cin >> x; s[i] = x; } for (int i = 1; i <= n; i++) { string x = s[i]; for (int j = 1; j <= n; j++) { if (x[j - 1] == 'C...
Problem: 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 ...
n = int(raw_input()) arr = [raw_input() for _ in xrange(n)] out = 0 for i in arr: j = i.count('C') out += j*(j - 1)/2 for i in xrange(n): k = [arr[j][i] for j in xrange(n)].count('C') out += k*(k - 1)/2 print out
Problem: 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 ...
# from dust i have come, dust i will be n = int(input()) s = [""] * n for i in range(n): s[i] = input() ans = 0 for i in range(n): for j in range(n): if s[i][j] == '.': continue # row for k in range(j + 1, n): if s[i][k] == 'C': ans += 1 ...
Problem: 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 ...
n = input() M = [] for _ in xrange(n): M.append(raw_input()) rowCounter = [0] * n colCounter = [0] * n for i in xrange(n): for j in xrange(n): if M[i][j] == 'C': rowCounter[i] += 1 for j in xrange(n): for i in xrange(n): if M[i][j] == 'C': colCounter[j] += 1 print s...
Problem: 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 ...
def ints(): return map(int, raw_input().split()) def floats(): return map(float, raw_input().split()) n, = ints() c = [] for i in range(n): s = raw_input() c.append(s) cnt = 0 for i in range(n): bars = c[i].count('C') cnt += bars * (bars - 1) / 2 bars = 0 for j in range(n): if...
Problem: 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 ...
import java.util.Scanner; public class Main1 { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); sc.nextLine(); char[][] a = new char[n][n]; for (int i = 0; i < n; i++) { a[i] = sc.nextLine().toCh...
Problem: 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 ...
#include <bits/stdc++.h> using namespace std; int r[200], c[200]; long long sum(int a, int b) { long long ans = b * (b - 1) / 2; return ans; } int main() { int n; cin >> n; char st[200]; for (int i = 1; i <= n; i++) { scanf("%s", st); for (int j = 0; j < strlen(st); j++) if (st[j] == 'C') { ...
Problem: 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 ...
#include <bits/stdc++.h> using namespace std; const int MAX = 100; int col[MAX], row[MAX], n, sum; string s; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> s; for (int j = 0; j < n; j++) { if (s[j] == 'C') { sum += col[j] + row[i], col[j]++, row[i]++; } } } cout << s...
Problem: 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 ...
import java.math.BigInteger; import java.util.Scanner; public class a629 { private static BigInteger factorial(long start, long stop) { BigInteger output = BigInteger.ONE; while (start > stop) { output = output.multiply(BigInteger.valueOf(start)); start--; } ...
Problem: 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 ...
#include <bits/stdc++.h> using namespace std; int row[101], col[101]; int main() { int n; cin >> n; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { char c; cin >> c; if (c == 'C') { row[i]++; col[j]++; } } } int ians = 0; for (int i = 0; i < n; i++...
Problem: 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 ...
#include <bits/stdc++.h> template <typename T> using Vector2D = std::vector<std::vector<T>>; template <typename T> using Vector3D = std::vector<Vector2D<T>>; using PairInt = std::pair<int, int>; using PairInt64 = std::pair<int64_t, int64_t>; using MapInt = std::map<int, int>; using MMapInt = std::multimap<int, int>; us...
Problem: 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 ...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<string> v(n); for (int i = 0; i < n; i++) { cin >> v[i]; } int ans = 0; for (int i = 0; i < n; i++) { int cnt = 0; for (auto x : v[i]) { if (x == 'C') { cnt++; } } ans += cnt * (cnt -...
Problem: 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 ...
#include <bits/stdc++.h> using namespace std; char a[101][101]; int main() { int n, i, j; int ans = 0; cin >> n; for (i = 0; i <= n - 1; i++) { for (j = 0; j <= n - 1; j++) { cin >> a[i][j]; } } for (i = 0; i <= n - 1; i++) { int count = 0; for (j = 0; j <= n - 1; j++) { if (a[i]...
Problem: 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 ...
n = int(input()) cols = [0]*n res = 0 for x in range(n): i = input() count = i.count('C') if count>=2: res+=count*(count-1)//2 for j,c in enumerate(i): if c == 'C': cols[j] += 1 print (res + sum((x * (x-1))//2 for x in cols if x > 1))
Problem: 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 ...
import java.io.BufferedReader; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int N = Integer.parseInt(br.readLine()); char[][] cake = new char[N][N]; for(int i=0;i<N;i++...
Problem: 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 ...
n=int(raw_input()) table=[[] for _ in xrange(n)] ans=0 for i in xrange(n): table[i]=raw_input() c=table[i].count('C') ans+=c*(c-1)//2 for i in xrange(n): c=0 for j in xrange(n): if table[j][i]=='C': c+=1 ans+=c*(c-1)//2 print ans
Problem: 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 ...
n=int(raw_input()) y=[] ans=0 for i in range(n): y.append(raw_input()) for i in range(n): count=0 for j in range(n): if y[i][j]=='C': count+=1 ans+=(count)*(count-1)/2 for i in range(n): count=0 for j in range(n): if y[j][i]=='C': count+=1 ans+=count*(count-1)/2 print ans
Problem: 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 ...
#include <bits/stdc++.h> using namespace std; int main() { int n; scanf("%d", &n); getchar(); char choclate[n][n + 1]; for (int i = 0; i < n; ++i) { scanf("%s", choclate[i]); } int happiness = 0; for (int i = 0; i < n; ++i) { int count_h = 0, count_v = 0; for (int j = n - 1; j >= 0; --j) { ...
Problem: 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 ...
#include <bits/stdc++.h> using namespace std; template <typename T> T in() { char ch; T n = 0; bool ng = false; while (1) { ch = getchar(); if (ch == '-') { ng = true; ch = getchar(); break; } if (ch >= '0' && ch <= '9') break; } while (1) { n = n * 10 + (ch - '0'); ...
Problem: 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 ...
import java.util.*; public class familDoor { public static void main(String[] args) { int n,count=0; Scanner in = new Scanner(System.in); n = in.nextInt(); String nextLine; char next; int[][] countArr = new int[2][n]; for(int i=0;i<n;i++) { nextLi...
Problem: 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 ...
n=int(input()) rc = [0]*n cc = [0]*n for j in range(n): s = input() for i in range(n): if s[i]=='C': cc[i]+=1 rc[j]+=1 def getPairs(n): if n>1: return (n*(n-1))//2 else: return 0 print(sum(map(lambda x:getPairs(x),rc))+sum(map(lambda x:getPairs(x),cc))...
Problem: 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 ...
#coding=utf-8 n=int(raw_input()) inputs=[] row=[0 for i in range(n)] col=[0 for i in range(n)] num=0 for i in range(n): inputs.append(raw_input()) for i in range(n): for j in range(n): if inputs[i][j]=='C': row[i]+=1 col[j]+=1 for i in range(n): if row[i]>=2: num+=row[i]*(row[i]-1)/2 if col[i]>=2: n...
Problem: 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 ...
/* Author : DEBOJYOTI MANDAL Attribute : Some of the methods are copied from GeeksforGeeks Website */ import java.util.*; import java.lang.*; import java.io.*; public class Main { //static Reader sc=new Reader(); static FastReader sc=new FastReader(System.in); public static void main (String[] args) throws j...
Problem: 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 ...
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner s=new Scanner(System.in); int n=s.nextInt(); char a[][]=new char[n][n]; s.nextLine(); for(int i=0;i<n;i++) { String k=s.nextLine(); for(int j=0;j<n;j++) { a[i][j]=k.charAt(j); } } int ans=0,c...
Problem: 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 ...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; char a[n][n]; int tot = 0; for (int i = 0; i < n; i++) { int ct = 0; for (int j = 0; j < n; j++) { cin >> a[i][j]; if (a[i][j] == 'C') ct++; } tot += ((ct * (ct - 1)) / 2); } for (int i = 0; i < n; i++)...
Problem: 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 ...
def binomialCoefficient(n, k): if(k > n - k): k = n - k res = 1 for i in range(k): res = res * (n - i) res = res / (i + 1) return res n = int(input()) cake = [] s = 0 for _ in range(n): cake.append(list(input())) for i in range(n): k = cake[i].count("C") if k == 1 ...
Problem: 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 ...
#include <bits/stdc++.h> using namespace std; const int N = 3010, mod = 1e9 + 7; char s[110][110]; int main() { int n; cin >> n; for (int i = 1; i <= n; i++) scanf("%s", s[i] + 1); int r = 0; for (int i = 1; i <= n; i++) { int c = 0; for (int j = 1; j <= n; j++) { if (s[i][j] == 'C') c++; } ...
Problem: 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 ...
n=int(raw_input()) r=[0 for i in xrange(n)] c=[0 for i in xrange(n)] for i in xrange(n): a=raw_input().strip() for j in xrange(n): if a[j]=='C': r[i]+=1 c[j]+=1 ans=0 for i in r:ans+=i*(i-1)/2 for i in c:ans+=i*(i-1)/2 print ans
Problem: 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 ...
#include <bits/stdc++.h> using namespace std; long long fact(int x) { long long ans = 0; while (x > 0) { ans += x; x--; } return ans; } int main() { int n; cin >> n; vector<vector<char> > a(n, vector<char>(n)); for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) cin >> a[i][j]; vector<...
Problem: 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 ...
PROBLEM = "A" FILE = "%s" %(PROBLEM) try: inFile = open(FILE+".txt") except: pass def read(): try: return inFile.readline().strip() except: return raw_input().strip() n = int(read()) cake = [] for _ in range(n): cake.append(read()) ans = 0 for i in range(n): cnt = cake[i]...
Problem: 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 ...
#include <bits/stdc++.h> using namespace std; int main(int argc, char const *argv[]) { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; char a[n][n]; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) cin >> a[i][j]; } int ans = 0; for (int i = 0; i < n; i++) { int c...
Problem: 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 ...
#include <bits/stdc++.h> int main() { int n, i, j, sum = 0, cnt; char board[100][100]; scanf("%d", &n); for (i = 0; i < n; i++) { cnt = 0; for (j = 0; j < n; j++) { scanf(" %c", &board[i][j]); if (board[i][j] == 'C') cnt++; } sum += cnt * (cnt - 1) / 2; } for (i = 0; i < n; i++) ...
Problem: 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 ...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; char m[n][n]; for (int i = 0; i < n; i++) scanf("%s", m[i]); int ans = 0; for (int i = 0; i < n; i++) { int cnt = 0; for (int j = 0; j < n; j++) if (m[i][j] == 'C') cnt++; ans += cnt * (cnt - 1) / 2; } for (int...
Problem: 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 ...
import java.io.*; import java.util.Arrays; import java.util.Collections; import java.util.StringTokenizer; public class TaskA { public static void main(String[] args) { In in = new In(System.in); PrintWriter out = new PrintWriter(System.out); // -- int n = in.nextInt(); ch...
Problem: 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 ...
import java.util.Scanner; public class BirthdayCake { public static void main(String[] args) { Scanner input = new Scanner(System.in); int x = input.nextInt(); char[][] grid = new char[x][x]; for(int i = 0; i < x; i++){ String in = input.next(); for(int j = 0; j < x; j++){ grid[i][j] = in.charAt(j)...
Problem: 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 ...
def solve(matrix, size): ans = 0 for i in range(size): cnt = 0 for j in range(size): if(matrix[i][j] == 'C'): cnt += 1 ans += cnt * (cnt - 1) / 2 cnt = 0 for j in range(size): if(matrix[j][i] == 'C'): cnt += 1 ans += cnt * (cnt - 1) / 2 return ans if(__name__ == '__main__'): size = int(r...
Problem: 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 ...
fact = [1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800, 39916800, 479001600, 6227020800, 87178291200, 1307674368000, 20922789888000, 355687428096000, 6402373705728000, 121645100408832000, 2432902008176640000, 51090942171709440000, 1124000727777607680000, 25852016738884976640000, 620448401733239439360000, 155112...
Problem: 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 ...
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Scanner; /** * Built using CHelper plug-in * Actual solution is at the top * * @author Safadurimo */ public class Main { public static void main(String[] args) { InputStrea...
Problem: 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 ...
from math import factorial as f n = int(input()) a = [] ans = 0 for i in range(n): b = input() a.append(b) c = b.count('C') if c > 1: ans += (f(c) // (2 * f(c - 2))) for i in range(n): c = 0 for j in range(n): if a[j][i] == 'C': c += 1 if c > 1: ans += ...
Problem: 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 ...
import java.util.*; import java.util.Scanner; public class FarRelativesBirthdayCake{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); //length of sides of cake String[] cakeS = new String[n]; for(int i = 0; i < n; i++){ //populate cakeS arr...
Problem: 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 ...
#include <bits/stdc++.h> using namespace std; int sumx[105]; int sumy[105]; char table[105][105]; int n; int main() { scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%s", table[i]); for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (table[i][j] == 'C') { sumx[i]++; sumy[...
Problem: 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 ...
n = int(input()) r = 0 c = 0 rows = [0]*n cols = [0]*n for i in range(n): st = input() rows[i] += st.count('C') for j in range(n): cols[j] += int(st[j] == 'C') print(sum([row*(row-1)//2 for row in rows if row > 0]) + sum([col*(col-1)//2 for col in cols if col > 0]))
Problem: 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 ...
n=int(input()) a=[] ans=0 for i in range(n): s=list(str(input())) a.append(s) for i in range(n): c=a[i][:].count('C') ans += c*(c-1)//2 for j in range(n): c=0 for k in range(n): c += a[k][j].count('C') ans += c*(c-1)//2 print(ans)
Problem: 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 ...
#include <bits/stdc++.h> using namespace std; char a[100][100]; int b[101]; int main() { int n; cin >> n; for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { cin >> a[i][j]; } } for (int i = 2; i <= n; ++i) { b[i] = i - 1 + b[i - 1]; } int sum = 0; for (int i = 0; i < n; ++i) {...
Problem: 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 ...
import java.util.*; import java.lang.*; import java.io.*; import java.math.*; public class practice{ public static void main(String[] args){ FastScanner inp = new FastScanner(); int n =inp.nextInt(); String[] arr = new String[n]; for(int i=0;i<n; i++) arr[i] = inp.next(); int []ar = new int...
Problem: 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 ...
n = int(input()) # 1 <= n <= 100 from sys import stdin from math import factorial lines = [stdin.readline() for i in range(n)] table = [list(line.strip()) for line in lines] table = [[1 if c == "C" else 0 for c in line] for line in table] t_table = list(map(list, zip(*table))) count = 0 for i in range(n): num = sum...
Problem: 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 ...
#include <bits/stdc++.h> using namespace std; long long revNumber(long long n) { long long b = 0; while (n != 0) { b = b * 10 + n % 10; n /= 10; } return b; } long long leapYearCheck(long long year) { if (year % 4 != 0) return 0; else if (year % 100 != 0) return 1; else if (year % 400 != 0...
Problem: 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 ...
#include <bits/stdc++.h> using namespace std; const int MX = 1e3; char arr[MX + 1][MX + 1]; long long int fact(long long int n) { long long int t = 1; for (int i = 2; i <= n; i++) { t *= i; } return t; } long long int C(long long int n, long long int r) { return fact(n) / (fact(r) * fact(n - r)); } int ma...
Problem: 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 ...
# import sys # sys.stdin=open("input.in",'r') # sys.stdout=open("outp.out",'w') n=int(input()) a=[input() for i in range(n)] c=0 for i in range(n): for j in range(n): if a[i][j]=='C': k=i+1 while k<n: if a[k][j]=='C': c+=1 k+=1 l=j+1 while l <n: if a[i][l]=='C': c+=1 l+=1 print...
Problem: 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 ...
import java.util.Scanner; import java.util.stream.IntStream; public class FarRelativeBirthdayCake { public static void main(String [] args) { Scanner input = new Scanner(System.in); int n = input.nextInt(), ans = 0; char [][] table = new char[n][n]; for(int i = 0; i < n; i++) ...