結果

問題 No.3030 ミラー・ラビン素数判定法のテスト
ユーザー 一野瀬翔吾一野瀬翔吾
提出日時 2024-04-30 22:19:25
言語 Go
(1.22.1)
結果
TLE  
実行時間 -
コード長 446 bytes
コンパイル時間 12,313 ms
コンパイル使用メモリ 232,692 KB
実行使用メモリ 13,888 KB
最終ジャッジ日時 2024-04-30 22:19:57
合計ジャッジ時間 23,671 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 2 ms
6,812 KB
testcase_02 AC 2 ms
6,812 KB
testcase_03 AC 9 ms
6,940 KB
testcase_04 TLE -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import "fmt"

func main() {
	var n int
	fmt.Scanf("%d", &n)
	for i := 0; i < n; i++ {
		var x uint64
		fmt.Scanf("%d", &x)
		if isPrime(x) {
			fmt.Printf("%d 1\n", x)
		} else {
			fmt.Printf("%d 0\n", x)
		}
	}
}

func isPrime(x uint64) bool {
	if x < 2 {
		return false
	}
	if x < 4 {
		return true
	}
	if x%2 == 0 {
		return false
	}
	for i := uint64(3); i*i <= x; i += 2 {
		if x%i == 0 {
			return false
		}
	}
	return true
}
0