結果

問題 No.1140 EXPotentiaLLL!
ユーザー 👑 tatt61880tatt61880
提出日時 2021-02-23 18:38:10
言語 Kuin
(KuinC++ v.2021.9.17)
結果
AC  
実行時間 1,048 ms / 2,000 ms
コード長 554 bytes
コンパイル時間 2,086 ms
コンパイル使用メモリ 148,728 KB
実行使用メモリ 8,480 KB
最終ジャッジ日時 2023-10-14 17:23:56
合計ジャッジ時間 12,735 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,037 ms
8,252 KB
testcase_01 AC 1,048 ms
8,376 KB
testcase_02 AC 1,039 ms
8,380 KB
testcase_03 AC 785 ms
8,468 KB
testcase_04 AC 633 ms
8,300 KB
testcase_05 AC 950 ms
8,168 KB
testcase_06 AC 941 ms
8,480 KB
testcase_07 AC 1,039 ms
8,300 KB
testcase_08 AC 37 ms
8,376 KB
testcase_09 AC 36 ms
8,232 KB
testcase_10 AC 36 ms
8,252 KB
testcase_11 AC 36 ms
8,268 KB
testcase_12 AC 36 ms
8,308 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

func main()
	var isPrime: []bool :: sieve(5000000)
	func sieve(n: int): []bool
		var isPrime: []bool :: [true].repeat(n + 1)
		do isPrime[0] :: false
		do isPrime[1] :: false
		for i(2, n)
			if(isPrime[i])
				var j: int :: i * i
				while(j <= n)
					do isPrime[j] :: false
					do j :+ i
				end while
			end if
		end for
		ret isPrime
	end func
	
	var t: int :: cui@inputInt()
	for(1, t)
		var a: int :: cui@inputInt()
		var p: int :: cui@inputInt()
		var ans: int :: isPrime[p] ?(a % p = 0 ?(0, 1), -1)
		do cui@print("\{ans}\n")
	end for
end func
0