結果

問題 No.781 円周上の格子点の数え上げ
ユーザー tsuchinagatsuchinaga
提出日時 2019-04-03 12:36:03
言語 Go
(1.21.3)
結果
AC  
実行時間 1,581 ms / 2,000 ms
コード長 542 bytes
コンパイル時間 11,759 ms
コンパイル使用メモリ 207,748 KB
実行使用メモリ 159,352 KB
最終ジャッジ日時 2023-08-22 20:44:10
合計ジャッジ時間 16,229 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 4 ms
4,380 KB
testcase_12 AC 779 ms
81,544 KB
testcase_13 AC 1,581 ms
159,352 KB
testcase_14 AC 7 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 843 ms
82,352 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import (
	"fmt"
	"math"
)

func main() {
	var min, max int
	_, _ = fmt.Scan(&min, &max)

	ans := 0
	rMap := make(map[int]int)
	minX, maxX := 1, int(math.Sqrt(float64(max)))
	for x := minX; x <= maxX; x++ {
		minY, maxY := 0, int(math.Sqrt(float64(max)-float64(x*x)))
		if min-x*x > 0 {
			minY = int(math.Ceil(math.Sqrt(float64(min) - float64(x*x))))
		}
		// fmt.Println(x, minY, maxY)
		for y := minY; y <= maxY; y++ {
			rMap[x*x+y*y]++
			if ans < rMap[x*x+y*y] {
				ans = rMap[x*x+y*y]
			}
		}
	}
	fmt.Println(ans * 4)
}
0