結果

問題 No.800 四平方定理
ユーザー dot_haraaidot_haraai
提出日時 2019-03-18 14:40:21
言語 Nim
(2.0.2)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,699 bytes
コンパイル時間 1,674 ms
コンパイル使用メモリ 56,388 KB
最終ジャッジ日時 2023-09-14 15:28:18
合計ジャッジ時間 2,536 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
/home/judge/data/code/Main.nim(5, 8) Error: cannot open file: queues

ソースコード

diff #

import strutils
import sequtils
import algorithm
import math
import queues
import tables
import sets
import future
 
const INF* = high(int) div 4
 
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 join*[T](a:openArray[T],sep:string=" "):string=
    result = $a[0]
    for i in 1..a.len-1:
        result = result & " " & $a[i]

proc readIntSeq*():seq[int]=
    readline().split().map(parseInt)

##################################################################


var
    (n,d) = readInt2()
    count1 = newseq[int](2*n^2)
    count2 = newseq[int](n^2+d)

for x in 1..n:
    for y in 1..n:
        count1[x^2+y^2-1] += 1
        if x^2-y^2+d > 0:
            count2[x^2-y^2+d-1]+=1
var r = 0
#echo count1
#echo count2
for i in 0..<min(2*n^2,n^2+d):
    r += count1[i]*count2[i]
echo r
0