結果
| 問題 |
No.800 四平方定理
|
| コンテスト | |
| ユーザー |
horiesiniti
|
| 提出日時 | 2023-02-04 19:46:56 |
| 言語 | Ruby (3.4.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 386 bytes |
| コンパイル時間 | 223 ms |
| コンパイル使用メモリ | 7,552 KB |
| 実行使用メモリ | 131,936 KB |
| 最終ジャッジ日時 | 2024-07-03 16:20:37 |
| 合計ジャッジ時間 | 28,062 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 TLE * 1 |
| other | AC * 14 TLE * 7 -- * 9 |
コンパイルメッセージ
Syntax OK
ソースコード
n,d=gets.split(" ").map{|e| e.to_i}
hs={}
hs2={}
1.upto(n){|x|
x.upto(n){|y|
t=x**2+y**2
hs[t]=0 if hs.member?(t)==false
hs[t]+=(x==y)?(1):(2)
t2=d+(x+y)*(x-y)
hs2[t2]=0 if hs2.member?(t2)==false
hs2[t2]+=1
next if x==y
t2=d+(y-x)*(x+y)
hs2[t2]=0 if hs2.member?(t2)==false
hs2[t2]+=1
}
}
ans=0
hs.each{|k,v|
next if hs2.member?(k)==false
ans+=v*hs2[k]
}
puts ans
horiesiniti