Submission #3602831


Source Code Expand

import strutils
import sequtils
import algorithm
import math
import queues
import tables
import sets
import future

const INF* = int(1e18 + 373)

proc readLine*(): string =
  stdin.readLine()
proc readSeq*(): seq[string] =
  readLine().strip().split()
proc readSeq*(n: Natural): seq[string] =
  result = newSeq[string](n)
  for i in 0..<n:
    result[i] = readLine().strip()
proc readInt1*(): int =
  readSeq().map(parseInt)[0]
proc readInt2*(): (int, int) =
  let a = readSeq().map(parseInt)
  return (a[0], a[1])
proc readInt3*(): (int, int, int) =
  let a = readSeq().map(parseInt)
  return (a[0], a[1], a[2])
proc readInt4*(): (int, int, int, int) =
  let a = readSeq().map(parseInt)
  return (a[0], a[1], a[2], a[3])
proc newSeqWith*[T](n: Natural; e: T): seq[T] =
  result = newSeq[T](n)
  for i in 0..<n:
    result[i] = e
type seq2*[T] = seq[seq[T]]
proc newSeq2*[T](n1, n2: Natural): seq2[T] =
  newSeqWith(n1, newSeq[T](n2))
type seq3*[T] = seq[seq[seq[T]]]
proc newSeq3*[T](n1, n2, n3: Natural): seq3[T] =
  newSeqWith(n1, newSeqWith(n2, newSeq[T](n3)))

#------------------------------------------------------------------------------#

proc main() =
  let (n, k) = readInt2()

  var x = newSeq[int](k)
  for i in 1..n:
    x[i mod k] += 1


  var ans = 0
  for a in 0..<k:
    let b = (k - a + k) mod k
    let c = (k - b + k) mod k
    if (c + a) mod k == 0:
      ans += x[a] * x[b] * x[c]

  echo ans

main()

Submission Info

Submission Time
Task C - Triangular Relationship
User somq14
Language Nim (0.13.0)
Score 300
Code Size 1487 Byte
Status AC
Exec Time 9 ms
Memory 1788 KB

Compile Error

Hint: system [Processing]
Hint: Main [Processing]
Hint: strutils [Processing]
Hint: parseutils [Processing]
Hint: sequtils [Processing]
Hint: algorithm [Processing]
Hint: math [Processing]
Hint: times [Processing]
Hint: queues [Processing]
Hint: tables [Processing]
Hint: hashes [Processing]
Hint: etcpriv [Processing]
Hint: sets [Processing]
Hint: os [Processing]
Hint: posix [Processing]
Hint: future [Processing]
Hint: macros [Processing]
Hint:  [Link]
Hint: operation successful (24543 lines compiled; 2.444 sec total; 23.235MB; Release Build) [SuccessX]

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 4
AC × 18
Set Name Test Cases
Sample s1.txt, s2.txt, s3.txt, s4.txt
All 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, s1.txt, s2.txt, s3.txt, s4.txt
Case Name Status Exec Time Memory
01.txt AC 3 ms 256 KB
02.txt AC 3 ms 256 KB
03.txt AC 3 ms 256 KB
04.txt AC 3 ms 256 KB
05.txt AC 2 ms 256 KB
06.txt AC 9 ms 1788 KB
07.txt AC 9 ms 1788 KB
08.txt AC 1 ms 256 KB
09.txt AC 8 ms 1788 KB
10.txt AC 2 ms 256 KB
11.txt AC 1 ms 256 KB
12.txt AC 2 ms 256 KB
13.txt AC 3 ms 256 KB
14.txt AC 2 ms 256 KB
s1.txt AC 1 ms 256 KB
s2.txt AC 1 ms 256 KB
s3.txt AC 1 ms 380 KB
s4.txt AC 1 ms 256 KB