結果

問題 No.371 ぼく悪いプライムじゃないよ
ユーザー yuki2006yuki2006
提出日時 2016-05-14 00:07:42
言語 Go
(1.22.1)
結果
WA  
実行時間 -
コード長 728 bytes
コンパイル時間 10,668 ms
コンパイル使用メモリ 231,512 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-04-19 08:02:48
合計ジャッジ時間 13,345 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
10,752 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 WA -
testcase_10 AC 1 ms
5,376 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 1 ms
5,376 KB
testcase_18 AC 1 ms
5,376 KB
testcase_19 WA -
testcase_20 AC 1 ms
5,376 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 TLE -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import (
	"fmt"
	"math"
)

func getSieve(N int) []int {
	field := make([]bool, N + 1)
	sieve := make([]int, 0)
	for k := 2; k <= N; k++ {
		if field[k] {
			continue
		}
		for v := k * k; v <= N; v += k {
			field[v] = true
		}
		sieve = append(sieve, k)
	}
	return sieve
}

func getMinSieve(n int) int {
	for k := 2; k <= n; k++ {
		if n % k == 0 {
			return k
		}
	}
	return -1
}
func main() {
	var L int
	var H int
	fmt.Scanf("%d", &L)
	fmt.Scanf("%d", &H)
	sieve := getSieve(int(math.Sqrt(float64(H)) + 5))
	for l := len(sieve) - 1; l >= 0; l-- {
		p := sieve[l]
		if p * p > H {
			continue
		}
		for m := H / p; m * p >= L; m-- {

			if getMinSieve(m) == p {
				fmt.Println(m * p)
				return
			}
		}
	}
}

0