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 ...
#include <bits/stdc++.h> const long double pi = 3.14159265359; const long double Exp = 2.71828182846; using namespace std; void Prepere_streams() { ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); } long long a[101] = {0}; int main() { int n; long long c = 0; char f; long long res = 0; cin >...
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()) res = 0 lis = [] for _ in range(N): lis.append(list(input())) l = [0]*N for i in range(N): row = 0 for j in range(N): if lis[i][j] == 'C': l[j]+=1 row+=1 res+=row*(row-1)/2 for i in l: res+=i*(i-1)/2 print(int(res))
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()) i=0 l=[] k=0 while i<n: s=raw_input() l.append(s) i=i+1 for x in l: if x.count('C')>=2: for m in range(1,x.count('C')): k=k+m i=0 a=0 while a<n: w=0 for x in l: if x[i]=='C': w=w+1 if w>=2: for j in range(1,w)...
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 ...
# https://codeforces.com/problemset/problem/629/A def nc2(a): return (a*(a-1))//2 n = int(input()) grid = [input() for x in range(n)] ans = 0 for x in range(n): ans += nc2(grid[x].count('C')) for x in range(n): ans+=nc2(sum([1 for y in range(n) if grid[y][x]=='C'])) 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 ...
from math import factorial n=int(raw_input()) d=[[]]*n for i in xrange(n): d[i]=raw_input() l1=0 for i in xrange(n): k=0 for i2 in xrange(n): if d[i][i2]=="C": k+=1 if k>1: l1+=factorial(k)/(factorial(2)*factorial(k-2)) l2=0 for i in xrange(n): k=0 for i2 in xrange(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.*; public class Birthday { static Scanner sc = new Scanner(System.in); static long pairs = 0; static int n; static char[][] a; static String s; public static void main(String[] args) { n = sc.nextInt(); a = new char[n][n]; for (int i = 0; i < n; i++) { s = sc.next(); for (int 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 chocolate(n, a): row = [0] * n col = [0] * n for i in range(0, n): for j in range(0, n): if a[i][j] == "C": row[i] += 1 col[j] += 1 #print(row) #print(col) total = 0 for each in row: total += (each * (each - 1) / 2) for each...
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.File; import java.io.FileNotFoundException; import java.io.IOException; import java.io.PrintWriter; import java.util.*; public class Main { public static void main(String[] args) throws FileNotFoundException { Scanner input = new Scanner(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 ...
def C(x): return x*(x-1)//2 n=int(input()) row=[0]*n col=[0]*n s=[list(input()) for _ in range(n)] for i in range(n): for j in range(n): row[i]+=(s[i][j]=='C') col[j]+=(s[i][j]=='C') ans=0 for i in range(n): ans+=C(row[i])+C(col[i]) 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 main() { long long int ans = 0; int a; scanf("%d", &a); char arr[a][a]; int arr2[2 * a]; for (int i = 0; i < a; i++) { scanf("%s", arr[i]); } for (int i = 0; i < 2 * a; i++) arr2[i] = 0; for (int i = 0; i < a; i++) { for (int j = 0; j < a; j++) { if (arr[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 math def ncr(n): f = math.factorial if(n>1): return (f(n) / (f(2) * f(n - 2))) else: return 0 n = int(input()) num = 0 arr = [0 for i in range(n)] for i in range(n): s = input() count = s.count('C') num += ncr(count) for i in range(n): if (s[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 ...
import java.io.BufferedReader; import java.io.InputStreamReader; /** * Created by andreilupu on 20/02/2016. */ public class A { public static void main(String[] args) { new A(); } public A(){ solve(); } private void solve() { try { BufferedReader in = new B...
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() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long t = 1; while (t--) { long long c = 0, n, d = 0, i, j, k, sum = 0; cin >> n; vector<long long> v; string s[n + 1]; for (i = 0; i < n; i++) { cin >> s[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, i, j, cnt = 0, f = 0; cin >> n; char a[n][n]; for (i = 0; i < n; i++) { for (j = 0; j < n; j++) { cin >> a[i][j]; if (a[i][j] == 'C') cnt++; } cnt = cnt * (cnt - 1) / 2; f += cnt; cnt = 0; } for (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 ...
n = int(input()) b = [0] * n c = [0] * n for i in range(n): t = input() for j in range(n): if t[j] == 'C': b[i] += 1 c[j] += 1 ans = 0 for i in range(n): ans += (b[i] * (b[i]-1))//2 ans += (c[i] * (c[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 ...
import java.util.*; /* Name of the class has to be "Main" only if the class is public. */ public class Main { public static void main (String[] args) throws java.lang.Exception { try { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); sc.nextLine(); int i,j,k=0,c=0,c1=0; Stri...
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 { static int count = 0; static int n; static char[][] map; static boolean[][] map1; public static void main(String[] args) { Scanner scanner = new Scanner(System.in); n = scanner.nextInt(); map = new char[n][n]; map1 = new boolean[n][n]; for(int i = 0;i < map....
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 cake { long comb(int n) { if(n<=1) return 0; else { if(n==3) return 3; else if(n>3) { int pro=n*(n-1); pro=pro/2; return pro; ...
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 birthday_cake_cf629a; import java.util.Scanner; public class Birthday_Cake_CF629A { public static void main(String[] args) { Scanner in = new Scanner(System.in); int N = in.nextInt(), total = 0; String C; boolean[][] Matrix = new boolean[N][N]; int[] Row = new 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 ...
import java.io.*; import java.util.*; //public class Main{ // codechef public class Solution{ // codeforces hackerrank //public class Contest629AFarRelativeBirthdayCake { static FastScanner in; static PrintWriter out; static final int mod = 1000000007; static final long modL = 100000000000000000l; //write co...
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 main() { int n, k; long long c = 0; cin >> n; for (int i = 0; i < n; i++) { cin >> s[i]; k = 0; for (int j = 0; j < n; j++) { if (s[i][j] == 'C') k++; } c += (k - 1) * k / 2; } for (int j = 0; j < n; j++) { k = 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()) matt=[] def factorial(x): if x<=1: return 1 return x*factorial(x-1) def combinations(num): if num<=1: return 0 com = factorial(num)/factorial(num-2)/2 return com happy=0 #take input and iterate over all rows for i in range(n): choco=0 row = list(input(...
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 op(x): return x * (x - 1) // 2 n = int(input()) #n, m = map(int, input().split()) #s = input() #c = list(map(int, input().split())) a = [] for i in range(n): s = input() a.append(s) s = 0 for i in range(n): x , y = 0, 0 for j in range(n): if a[i][j] == 'C': x += 1 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.io.*; import java.util.*; public class ForProblems { Random rnd = new Random(); void solve() throws IOException { int n = readInt(); char[][] a = new char[n][n]; for (int i = 0; i < n; ++i) { String tmp = readString(); 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.util.*; import java.io.*; public class P629A { private static void solve() { int n = nextInt(); char[][] g = new char[n][n]; for (int i = 0; i < n; i++) { g[i] = next().toCharArray(); } int ans = 0; for (int i = 0; i < n; i++) { int cnt = 0; for (int 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; int main() { int n, t = 0, c = 0; char ch[105][105]; cin >> n; for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) cin >> ch[i][j]; for (int i = 1; i <= n; i++) { c = 0; for (int j = 1; j <= n; j++) { if (ch[i][j] == 'C') c++; } 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() { long long int n; vector<pair<int, int>> v; cin >> n; string s[n]; for (long long int i = 0; i < n; i++) { cin >> s[i]; for (long long int j = 0; j < n; j++) { if (s[i][j] == 'C') v.push_back({i, j}); } } long long int count = 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.Arrays; import java.util.Scanner; public class Main { public static void main(String [] args) { Scanner in = new Scanner(System.in); Task task = new Task(); task.solve(in); } } class Task { final int MAXN = 105; char [][] board = new char[MAXN][MAXN]; publ...
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 int nCr(long long int n, long long int r) { return (n * (n - 1)) / 2; } void solve() { long long 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]; } } long long int ans = 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.io.*; import java.util.*; public class cf { static class FastScanner { BufferedReader br; StringTokenizer st; public FastScanner() { try { br = new BufferedReader(new InputStreamReader(System.in)); st = new StringTokenizer(br.readLine()...
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 mass[101][101]; long res = 0; for (int i = 0; i < n; i++) { int cCount = 0; cin >> mass[i]; for (int k = 0; k < n; k++) { if (mass[i][k] == 'C') { cCount++; } } res += (cCount * (cCount - 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 ...
# your code goes here n=input() a=[] c=0 for i in xrange(n): s=list(raw_input()) n1 = s.count('C') c += n1*(n1-1)/2 a += [s] a = [list(x) for x in zip(*a)] for i in xrange(n): n1 = a[i].count('C') c += n1*(n1-1)/2 print 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 ...
def main(): n = int(input()) data = [] for i in range(n): data.append(input()) res = 0 for i in range(0, n): s = 0 for j in range(0, n): for l in range(j+1,n): if data[i][j]==data[i][l] and data[i][j]=='C': s+=1 res+=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 ...
n = int(input()) matrix = [] res = 0 for i in range(n): matrix.append(input()) rowCount, colCount = 0, 0 for i in range(n): for j in range(n): if matrix[i][j] == "C": rowCount += 1 if matrix[j][i] == "C": colCount += 1 res += (rowCount - 1) * rowCount // 2 + (colCoun...
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()) l=[[0]*n for i in range(n)] for i in range(n): s=input() for k in range(n): if s[k]=='C':l[i][k]+=1 res=0 for i in range(n): tmp=sum(l[i]) if tmp!=0:res+=(tmp-1)*tmp//2 tmp=0 for j in range(n):tmp+=l[j][i] if tmp!=0:res+=(tmp-1)*tmp//2 print(res)
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()) cake={} for i in range(n): row=input() for j in range(n): cake[(i,j)]=row[j] h=0 for i in range(n): for j in range(n): for k in range(j+1,n): '''if cake[(i,j)]=='C' and cake[(i,k)]=='C': print((i,j),(i,k))''' h += 1 if cake[(i,j)]=='C' a...
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() { long long n; cin >> n; char arr[n][n]; int row[n]; int col[n]; for (long i = 0; i < n; i++) { row[i] = 0; col[i] = 0; } for (long i = 0; i < n; i++) { for (int j = 0; j < n; j++) { char c; cin >> c; arr[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 ...
#include <bits/stdc++.h> using namespace std; int main() { char arr[120][120]; int n; cin >> n; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { cin >> arr[i][j]; } } int count = 0; long ans = 0; for (int i = 0; i < n; i++) { 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 ...
#!/usr/bin/python3 import math def combination(n, r): return math.factorial(n) // (math.factorial(n-r)*math.factorial(r)) if __name__ == '__main__': n = int(input()) col = [0 for i in range(n)] row = [0 for i in range(n)] res = 0 for i in range(n): s = input() for j in range(...
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 fac (n): t = 1 for i in range(1,n+1): t = t * i return(t) N = int(input()) y = [] a,b= 0,0 for i in range(N): y += list(map(str , input() .split())) for i in range(N): r = y[i].count('C') if r > 1 : a += fac(r) / (fac(2)*fac(r - 2)) c = int(a) for j in range(N): for k 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.Arrays; import java.util.Scanner; public class FarRelativeBirthdayCake { public static void main(String[] args) { Scanner s = new Scanner(System.in); int n = s.nextInt(); int[] rows = new int[n]; int[] cols = new int[n]; Arrays.fill(rows, 0); Arrays.fill(cols, 0); for(int i = 0; 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=input() s=[raw_input() for i in range(n)] R=0 for i in s: N=i.count('C') R+=N*(N-1)/2 for i in zip(*s): N=i.count('C') R+=N*(N-1)/2 print 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 ...
def total(a): if a==0 or a==1:return(0) else: return(((a-1)*a)//2) d,c=[],0 n=int(input()) for x in range(n): l=list(input()) a=l.count("C") c+=total(a) d.append(l) for r in range(n): z=0 for s in range(n): if d[s][r]=="C":z+=1 c+=total(z) print(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 ...
// Problem : A. Far Relative’s Birthday Cake // Contest : Codeforces Round #343 (Div. 2) // URL : https://codeforces.com/contest/629/problem/A // Memory Limit : 256 MB // Time Limit : 1000 ms // Powered by CP Editor (https://github.com/cpeditor/cp-editor) import java.io.*; import java.util.*; public class a { pu...
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 double C(long long int n, long long int k) { long double res = 1; if (k > n - k) { k = n - k; } for (long long int i = 0; i < k; i++) { res *= (n - i); res /= (i + 1); } return res; } int main() { long long int n; cin >> n; char a[n + 1][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.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.ArrayList; import java.util.StringTokenizer; import java.ut...
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; static array<array<bool, 100>, 100> arr; int main() { size_t n; cin >> n; unsigned long long ans = 0; for (size_t i = 0; i < n; ++i) { string s; cin >> s; for (size_t j = 0; j < n; ++j) { arr[i][j] = (s[j] == '.' ? 0 : 1); } } for (size_t 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.ArrayList; import java.util.Scanner; public class FamilDoor { public static void main(String ... arg){ Scanner s = new Scanner(System.in); int n = s.nextInt(); int rowCount = 0,chocosInRow = 0; int colCount = 0,chocosInCol = 0; ArrayList<String> cake = new ArrayList(); cake.add(s.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()) result = 0 arr = [0] * n for i in range(n): s = input() result += sum(range(s.count('C'))) for j, ch in enumerate(s): arr[j] += ch == 'C' for i in range(n): result += sum(range(arr[i])) print(result)
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()) c = [list(input()) for i in range(n)] ans = 0 for i in range(n): t = c[i].count('C') ans += t*(t-1)//2 c = list(zip(*c)) for i in range(n): t = c[i].count('C') ans += t*(t-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 ...
import math n = int(raw_input()) def C(n, k): return math.factorial(n) / (math.factorial(k) * math.factorial(n-k)) total = 0 rows = [0 for i in range(0, n)] for i in range(0, n): s = raw_input() num = 0 for j in range(0, len(s)): if s[j] == 'C': rows[j] += 1 num ...
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.Scanner; public class Main { public static void main(String[] args) throws IOException { Scanner in = new Scanner(System.in); byte n = in.nextByte(); String str[] = new String[n]; int cR = 0, cC = 0, sum = 0; for (byte 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()) Sum1=0;Sum2=0 has=[0 for i in range(n)] for item in range(n): Sum=0 st=raw_input() #print x[item] for i in range(len(st)): if st[i]=="C": Sum+=1 has[i]+=1 Sum1+=Sum*(Sum-1)/2 for item in has: Sum2+=item*(item-1)/2 print Sum1+Sum2
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 FarRelativesBirthdayCake { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); char[][] A = new char[n][n]; scan.nextLine(); for(int i = 0; i < n; i++) { String S = scan.nextLine(); for(int j = 0; j < n; j++) { A[...
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.*; import static java.lang.Math.*; import static java.util.Arrays.*; public class Main { public static FastScanner in=new FastScanner(); public static void main(String[] args) throws IOException { int n=in.nextInt(); char[][]a=new char[n][n]; for(int i=0; i<n; ++i){ char []...
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 = [[] for _ in range(n)] c = 0 for it in range(n): arr[it] = list(raw_input()) numc = sum(x == 'C' for x in arr[it]) c += numc * (numc - 1) / 2 for it in range(n): column = [arr[i][it] for i in range(n)] numc = sum(x == 'C' for x in column) c += numc * (numc - 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 ...
import math def nCr(n,r): f = math.factorial return f(n) / f(r) / f(n-r) n = int(input()) a=[] b=[0]*n for i in range(n): line = list(input()) count = line.count('C') a.append(count) for k,m in enumerate(line): if m=='C': b[k] += 1 total = 0 for i,s in enumerate(a): ...
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/env python #-*- coding:utf-8 -*- import sys, math, random, operator from string import ascii_lowercase from string import ascii_uppercase from fractions import Fraction, gcd from decimal import Decimal, getcontext from itertools import product, permutations, combinations from Queue import Queue, PriorityQue...
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 n = int(input()) a = [] for i in range(n): temp = input() a.append(temp) r = [0]*n c = [0]*n for i in range(n): for j in range(n): if a[i][j] == 'C': r[i] += 1 c[j] += 1 ans = 0 comb = lambda x, y: factorial(x)//factorial(y)//factorial(x-y) for (i, j) in zip(r, c): if i >= 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 ...
import java.util.*; import java.lang.*; import java.io.*; import java.math.*; public class Main{ public static void main (String[] args) throws java.lang.Exception{ //BufferedReader in=new BufferedReader(new InputStreamReader(System.in)); InputReader in=new InputReader(System.in); Prin...
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.text.*; import java.math.*; import java.util.regex.*; public class Solution { public static void main(String[] args) { Scanner s =new Scanner(System.in); int n=s.nextInt(); int a[][] = new int[n][n]; s.nextLine(); 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 ...
n=int(input()) l=[] res=0 for i in range(n): l.append(list(input())) y=list(zip(*l)) for i in range(n): x=l[i].count('C') b=y[i].count('C') res+=((x-1)*x)//2+((b-1)*b)//2 print(res)
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 C(k): return (k*(k-1))//2 n=int(input()) r=[0 for i in range(n)] c=[0 for i in range(n)] for i in range(n): s=input() for j in range(n): if s[j]=='C': r[i]+=1 c[j]+=1 ans=0 for i in range(n): ans+=(C(r[i])+C(c[i])) 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(input()) table = [input() for i in range(N)] ans = 0 for i in range(N): cnt = 0 for j in range(N): if table[i][j] == "C": cnt += 1 ans += cnt * (cnt - 1) // 2 for j in range(N): cnt = 0 for i in range(N): if table[i][j] == "C": cnt += 1 ans += cn...
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() { char ch[1011][1001], s; int l, n, r = 0, i, k, m, j; int a[1000005] = {0}, b[100001], c[10001], d[10001]; cin >> n; long long ans = 0; for (i = 1; i <= n; i++) { r = 0; for (j = 1; j <= n; j++) { cin >> ch[i][j]; if (ch[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 java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; import java.util.Set; import java.util.Map.Entry; import java.util.HashMap; import java.util.Iterator; import java.math.BigDecimal; public class test { public static void main(String[] args) { Scanner...
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() { ios_base::sync_with_stdio(false); cin.tie(0); long long int x, y, z, n, res = 0, k; cin >> n; vector<string> v; for (int i = 0; i < n; i++) { string s; cin >> s; v.push_back(s); } for (int i = 0; i < v.size(); i++) { k = 0; f...
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.Arrays; import java.util.Scanner; /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ /** * * @author Dell */ public class NewMain37 { ...
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 Solution { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = Integer.parseInt(scanner.nextLine()); List<String> layers = new ArrayList<String>(); int total = 0; for (...
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()) cake = [list(input()) for i in range(n)] pairs = 0 for row in range(n): for col in range(n-1): if cake[row][col] == "C": for second in range(col+1, n): if cake[row][second] == "C": pairs += 1 for col in range(n): for row in range(n-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 ...
#! /usr/bin/env python # -*- coding: utf-8 -*- # vim:fenc=utf-8 # # Copyright © 2016 missingdays <missingdays@missingdays> # # Distributed under terms of the MIT license. """ """ n = int(input()) s = [] for i in range(n): s.append(input()) answ = 0 for i in range(n): for j in range(n): if s[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 ...
n = input() l = list() for i in range(n): l.append(raw_input()) s = 0 for i in range(n): a = len([c for c in l[i] if c == 'C']) b = len([l[j][i] for j in range(n) if l[j][i] == 'C']) s += a * (a-1) / 2 + b * (b-1) / 2 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 ...
from math import factorial as f if __name__=='__main__': n= int(input()) if n==1: t = input() if t=='C': print(1) else: print(0) else: hapi = 0 ck = [] for i in range(n): t = input() c = t.count('C') if c > 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 static java.lang.Math.ceil; import static java.lang.Math.log; import java.util.ArrayList; import java.util.Scanner; import java.util.*; import java.io.*; public class main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); long n, 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; char a[105][105]; int main() { int n; cin >> n; long long ans = 0; for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) cin >> a[i][j]; for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) { if (a[i][j] == 'C') { for (int k = j + 1; 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 ...
#include <bits/stdc++.h> #pragma comment(linker, "/STACK:66777216") #pragma warning(disable : 4996) #pragma hdrstop namespace std {} namespace Random {} inline bool is_digit(const char ch) { return (ch >= '0' && ch <= '9'); } class IO { public: constexpr static const std::size_t kBufferSize = 1 << 18; IO() :...
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 maxn = 1e2 + 5; const int inf = 1e9; const int mod = 1e9 + 7; char a[maxn][maxn]; int c[maxn]; int r[maxn]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; int n; cin >> n; for (int i = 0; i < n; i++) 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; template <typename T> void chmax(T& a, const T& b) { if (a < b) a = b; } template <typename T> void chmin(T& a, const T& b) { if (b < a) a = b; } int N; int main() { cin.tie(0); ios::sync_with_stdio(false); cin >> N; vector<string> cake(N); for (int i = (0); 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 ...
x = int(input()) t = 0 s = 0 n = 0 n1 = 0 d = 0 z = [] for i in range(x): a = input() z.append(a) n = a.count("C") if n >1: k = int(n*(n-1)/2) else: k = 0 s = s + k for i in range(x): t = 0 for j in range(x): if z[j][i] == "C": t = t + 1 if t>1: l = int(t*(t-1)/2) else: l = 0 d = d + l print(d+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 ...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int T; cin >> T; vector<string> cake; for (int i = 0; i < T; ++i) { string x; cin >> x; cake.push_back(x); } int res = 0; for (int i = 0; i < T; ++i) { int row ...
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 { private static final Scanner scanner = new Scanner(System.in); public static void main(String[] args) { int n = scanner.nextInt(); char[][] c = new char[n][n]; int[] cons = new int[101]; int a = 1, b = 2, sum = 0, numV = 0, numC = 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 math cache = {0:0, 1:0, 2:1, 3:3, 4:6} fac = {0:0, 1:1, 2:2, 3:6, 4:24} def f(n): fun = math.factorial if n in fac: return fac[n] a = fun(n) fac[n] = a return fun(n) def nCr(n,r): if n in cache: return cache[n] a = f(n) / f(r) / f(n-r) cache[n] = a return a ...
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]; } } int ans = 0; for (int i = 0; i < n; i++) { int cnt = 0; for (int j = 0; j < n; j++) { if (arr[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 java.io.*; public class Cake { public static void main(String args[]) throws IOException { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); String s1=new String(br.readLine()); int n=Integer.parseInt(s1); String[] s2=new String[n]; char[]...
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 * import sys n = int(sys.stdin.readline()) m = [] cntInColumn = cntInRows = 0 total = 0 for i in range(n): vec = [] for j in range(n): c = sys.stdin.read(1) cntInRows = cntInRows + 1 if c == 'C' else cntInRows vec.append(c) total += factorial(cntInRows) // (fact...
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 = [] b = [] m = 0 ans = 0 for i in range(n): s = input() for j in range(n): b.append(s[j]) a.append(b[:]) b.clear() for m in range(n): for i in range(n - 1): for j in range(i + 1, n, 1): if a[m][i] == a[m][j] == "C": ans += 1 for m in ra...
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.Arrays; import java.util.Scanner; public class Main { MyScanner sc = new MyScanner(); Scanner sc2 = new Scanner(System.in); long start = System.currentTimeMillis(); long fin = System.currentTimeMillis(); final int MOD = 1000000007; int[] dx = { 1, 0, 0, -1 }; int[] dy = { 0, 1, -1, 0 }; void ...
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 ...
li= [] n = int(input()) for i in range(n): a = list(input()) li.append(a) k = 0 c = 0 for i in range(n): k = li[i].count('C') c += k*(k-1)//2 k= 0 for j in range(n): for l in range(n): if li[l][j]=='C': k+=1 c += k*(k-1)//2 k = 0 print(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 ...
D = {'1': 1, '3': 6, '5': 120, '7': 5040, '9': 362880, '31': 8222838654177922817725562880000000, '30': 265252859812191058636308480000000, '33': 8683317618811886495518194401280000000, '32': 263130836933693530167218012160000000, '35': 10333147966386144929666651337523200000000, '34': 295232799039604140847618609643520000...
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 = [] ans = 0 for i in range(N): arr.append(list(raw_input())) cnt = 0 for j in range(N): cnt += arr[i][j]=='C' ans += cnt*(cnt-1)/2 for i in range(N): cnt = 0 for j in range(N): cnt += arr[j][i]=='C' ans += cnt*(cnt-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 ...
a=int(input()) c=[[] for i in range(a)] h=0 for i in range(a): b=input() for j in range(a): c[i].append(b[j]) h+=b.count('C')*(b.count('C')-1)//2 for j in range(a): num=0 for i in range(a): if c[i][j]=='C':num+=1 h+=num*(num-1)//2 print(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 ...
import java.io.PrintWriter; import java.lang.String; import java.util.Scanner; public class A { public static void main(String[] args) { // TODO Auto-generated method stub Scanner reader = new Scanner(System.in); PrintWriter writer= new PrintWriter(System.out); int n = Integer.parseInt(reader.nextLine()); ...
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()) cake = ['' for i in range(n)] for i in range(n): cake[i] = raw_input() ans = 0 for c in cake: k = c.count('C') ans += k * (k-1)/2 for i in range(n): k = len([c[i] for c in cake if c[i] == '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 ...
import operator def nC2(n): return (n*n - n) // 2 n = int(input()); acc, s = [0] * n, 0 for i in range(n): xs = [1 if c == 'C' else 0 for c in input()] acc = map(operator.add, acc, xs) s += nC2(sum(xs)) s += sum(map(nC2, acc)) 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 ...
import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class Main { static Scanner s = new Scanner(); static PrintWriter out = new PrintWriter(System.out); public static void main(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 ...
n = int(input()) ans = 0 def fact(n): ans = 1 for i in range(2, n+1): ans*=i return ans cols = [0 for i in range(n)] rows = [0 for i in range(n)] grid = [] for i in range(n): grid.append(list(input())) for r in range(n): for c in range(n): if(grid[r][c]=='C'): rows[r]+=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; int n, a[1001], b[1001], ans = 0; char x[101][101]; int main() { cin >> n; for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { cin >> x[i][j]; if (x[i][j] == 'C') { ans += a[i]++; ans += b[j]++; } } } cout << 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 combi(long long n, long long x) { if (n < x) return 0; long long ans = 1; for (int i = 1; i <= x; i++) ans = ans * (n - i + 1) / i; return ans; } int main() { int r[101] = {0}, c[101] = {0}; int n; string s; cin >> 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 ...
#include <bits/stdc++.h> using namespace std; const long long N = 2e5 + 7; const long long M = 1e9 + 7; const long long H = 1e5 + 7; const long long B = 1e4 + 7; const long long A = 1e6 + 7; map<long long, long long> mp, pm; deque<long long> v, vc, ve; deque<char> p, pe; deque<string> ts, ss; deque<double> sd; long lon...
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() { long long com[101][5] = {{0}}; for (int i = 0; i <= 100; i++) com[i][0] = 1; for (int i = 1; i <= 100; i++) { for (int j = 1; j <= 4; j++) { com[i][j] = com[i - 1][j - 1] + com[i - 1][j]; } } long long n; string cake[110]; long long ...