結果

問題 No.1593 Perfect Distance
ユーザー 👑 horiesinitihoriesiniti
提出日時 2023-01-19 01:41:15
言語 Ruby
(3.3.0)
結果
AC  
実行時間 132 ms / 2,000 ms
コード長 271 bytes
コンパイル時間 493 ms
コンパイル使用メモリ 11,432 KB
実行使用メモリ 20,260 KB
最終ジャッジ日時 2023-09-02 18:34:25
合計ジャッジ時間 4,415 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 101 ms
20,060 KB
testcase_01 AC 101 ms
20,092 KB
testcase_02 AC 107 ms
20,208 KB
testcase_03 AC 103 ms
20,024 KB
testcase_04 AC 106 ms
20,060 KB
testcase_05 AC 103 ms
20,004 KB
testcase_06 AC 102 ms
20,244 KB
testcase_07 AC 104 ms
20,140 KB
testcase_08 AC 104 ms
20,036 KB
testcase_09 AC 104 ms
20,244 KB
testcase_10 AC 107 ms
20,092 KB
testcase_11 AC 110 ms
20,240 KB
testcase_12 AC 113 ms
20,116 KB
testcase_13 AC 114 ms
20,212 KB
testcase_14 AC 117 ms
20,112 KB
testcase_15 AC 123 ms
20,212 KB
testcase_16 AC 132 ms
20,260 KB
testcase_17 AC 101 ms
20,144 KB
testcase_18 AC 102 ms
20,092 KB
testcase_19 AC 103 ms
20,208 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

def f(m,n)
	return m**4+n**4+2*n*n*m*m
end
hs={}
100000.times{|i|
	hs[i*i]=0
}
n0=gets.to_i
n0=n0*n0
m=2
ans=0
while m**4<=n0 do
	1.upto(m-1){|n|
		c=f(m,n)
		break if c>n0
		next if m.gcd(n)!=1 || (m-n)%2==0
		ans+=2 if n0%c==0 && hs.member?(n0/c)
	} 
	m+=1
end
puts ans
0