結果
問題 | No.1058 素敵な数 |
ユーザー | tenten |
提出日時 | 2020-09-28 14:28:59 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 126 ms / 2,000 ms |
コード長 | 831 bytes |
コンパイル時間 | 2,327 ms |
コンパイル使用メモリ | 74,056 KB |
実行使用メモリ | 56,048 KB |
最終ジャッジ日時 | 2023-09-14 18:34:19 |
合計ジャッジ時間 | 4,538 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 125 ms
55,732 KB |
testcase_01 | AC | 126 ms
56,048 KB |
testcase_02 | AC | 125 ms
56,016 KB |
testcase_03 | AC | 124 ms
55,756 KB |
testcase_04 | AC | 124 ms
55,992 KB |
testcase_05 | AC | 125 ms
55,764 KB |
testcase_06 | AC | 125 ms
55,568 KB |
testcase_07 | AC | 125 ms
55,792 KB |
testcase_08 | AC | 126 ms
55,596 KB |
testcase_09 | AC | 125 ms
55,760 KB |
ソースコード
import java.util.*; public class Main { static final int MOD = 1000000007; public static void main (String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); TreeSet<Integer> primes = new TreeSet<>(); int num = 100001; while (primes.size() < 10) { if (isPrime(num)) { primes.add(num); } num += 2; } TreeSet<Long> ans = new TreeSet<>(); ans.add(1L); for (int x : primes) { for (int y : primes) { ans.add((long)x * y); } } int idx = 1; for (long x : ans) { if (idx == n) { System.out.println(x); return; } idx++; } } static boolean isPrime(int x) { for (int i = 2; i <= Math.sqrt(x); i++) { if (x % i == 0) { return false; } } return true; } }