Created
June 3, 2021 00:14
-
-
Save sakapon/6b576cd576f0ac72e8d92a992d8e4512 to your computer and use it in GitHub Desktop.
競プロ典型 90 問 / Q046
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Linq; | |
class Q046 | |
{ | |
const int M = 46; | |
static int[] Read() => Array.ConvertAll(Console.ReadLine().Split(), int.Parse); | |
static void Main() | |
{ | |
var n = int.Parse(Console.ReadLine()); | |
var r = new bool[3].Select(_ => Read()).Select(Tally).Aggregate(Convolve); | |
Console.WriteLine(r[0]); | |
} | |
static long[] Tally(int[] a) | |
{ | |
var r = new long[M]; | |
foreach (var x in a) ++r[x % M]; | |
return r; | |
} | |
static long[] Convolve(long[] a, long[] b) | |
{ | |
var r = new long[M]; | |
for (int i = 0; i < M; i++) | |
for (int j = 0; j < M; j++) | |
r[(i + j) % M] += a[i] * b[j]; | |
return r; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://atcoder.jp/contests/typical90/submissions/23141056