結果

問題 No.152 貯金箱の消失
ユーザー tnoda_tnoda_
提出日時 2015-03-19 16:14:59
言語 Go
(1.22.1)
結果
AC  
実行時間 24 ms / 5,000 ms
コード長 441 bytes
コンパイル時間 11,684 ms
コンパイル使用メモリ 223,312 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-18 10:16:01
合計ジャッジ時間 11,619 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 5 ms
5,376 KB
testcase_08 AC 24 ms
5,376 KB
testcase_09 AC 24 ms
5,376 KB
testcase_10 AC 17 ms
5,376 KB
testcase_11 AC 11 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import (
	"fmt"
)

func gcd(a, b int64) int64 {
	if a < b {
		gcd(b, a)
	}
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func coprime(m, n int64) bool {
	return gcd(m, n) == 1
}

func main() {
	var L, res int64
	fmt.Scan(&L)
	L /= 4
	for m := int64(2); 2*m*m < L; m++ {
		for n := (m & 1) + 1; n < m && 2*m*(m+n) <= L; n += 2 {
			if !coprime(m, n) {
				continue
			}
			res++
			res %= 1000003
		}
	}
	fmt.Println(res)
}
0