結果

問題 No.1140 EXPotentiaLLL!
ユーザー 👑 tatt61880tatt61880
提出日時 2021-02-23 18:36:54
言語 Kuin
(KuinC++ v.2021.9.17)
結果
AC  
実行時間 987 ms / 2,000 ms
コード長 552 bytes
コンパイル時間 2,207 ms
コンパイル使用メモリ 148,364 KB
実行使用メモリ 8,476 KB
最終ジャッジ日時 2023-10-14 17:23:43
合計ジャッジ時間 12,767 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 958 ms
8,360 KB
testcase_01 AC 987 ms
8,328 KB
testcase_02 AC 948 ms
8,412 KB
testcase_03 AC 741 ms
8,412 KB
testcase_04 AC 586 ms
8,464 KB
testcase_05 AC 925 ms
8,384 KB
testcase_06 AC 872 ms
8,416 KB
testcase_07 AC 973 ms
8,400 KB
testcase_08 AC 34 ms
8,476 KB
testcase_09 AC 35 ms
8,452 KB
testcase_10 AC 35 ms
8,200 KB
testcase_11 AC 37 ms
8,228 KB
testcase_12 AC 37 ms
8,432 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

func main()
	var primes: []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 :: primes[p] ?(a % p = 0 ?(0, 1), -1)
		do cui@print("\{ans}\n")
	end for
end func
0