結果

問題 No.152 貯金箱の消失
ユーザー yukirinyukirin
提出日時 2016-03-03 23:29:27
言語 Go
(1.22.1)
結果
WA  
実行時間 -
コード長 826 bytes
コンパイル時間 11,629 ms
コンパイル使用メモリ 219,492 KB
実行使用メモリ 199,168 KB
最終ジャッジ日時 2024-04-19 06:54:48
合計ジャッジ時間 14,105 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,248 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 4 ms
5,376 KB
testcase_05 AC 5 ms
5,376 KB
testcase_06 AC 14 ms
7,936 KB
testcase_07 AC 65 ms
36,480 KB
testcase_08 AC 578 ms
198,528 KB
testcase_09 AC 583 ms
199,168 KB
testcase_10 WA -
testcase_11 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func main() {
	sc.Split(bufio.ScanWords)
	l := nextInt()
	count := 0
	for _, v := range revEuclid(int(math.Sqrt(float64(l))), 1, 1) {
		a, b, c := v[0]*v[0]-v[1]*v[1], 2*v[0]*v[1], v[0]*v[0]+v[1]*v[1]
		if l > 4*(a+b+c) {
			count++
			count %= 1000003
		}
	}
	fmt.Println(count)
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(nextLine())
	return i
}

func revEuclid(n, a, b int) [][]int {
	ret := make([][]int, 0, 2000)

	var f func(int, int, int)
	f = func(m, c, d int) {
		for e := c + d; e <= m; e += d {
			if (e-d)%2 == 1 {
				ret = append(ret, []int{e, d})
			}
			f(n, d, e)
		}
	}
	f(n, a, b)
	return ret
}
0