結果
問題 | No.1396 Giri |
ユーザー | tenten |
提出日時 | 2021-11-30 10:10:48 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 96 ms / 2,000 ms |
コード長 | 1,714 bytes |
コンパイル時間 | 2,185 ms |
コンパイル使用メモリ | 73,852 KB |
実行使用メモリ | 55,624 KB |
最終ジャッジ日時 | 2023-09-16 01:49:45 |
合計ジャッジ時間 | 5,061 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 43 ms
49,388 KB |
testcase_01 | AC | 43 ms
49,516 KB |
testcase_02 | AC | 96 ms
55,396 KB |
testcase_03 | AC | 45 ms
49,312 KB |
testcase_04 | AC | 44 ms
49,564 KB |
testcase_05 | AC | 94 ms
55,496 KB |
testcase_06 | AC | 45 ms
49,384 KB |
testcase_07 | AC | 45 ms
49,364 KB |
testcase_08 | AC | 45 ms
49,620 KB |
testcase_09 | AC | 44 ms
47,700 KB |
testcase_10 | AC | 45 ms
49,544 KB |
testcase_11 | AC | 44 ms
49,476 KB |
testcase_12 | AC | 44 ms
49,808 KB |
testcase_13 | AC | 45 ms
49,816 KB |
testcase_14 | AC | 45 ms
49,652 KB |
testcase_15 | AC | 44 ms
49,712 KB |
testcase_16 | AC | 45 ms
49,432 KB |
testcase_17 | AC | 48 ms
49,428 KB |
testcase_18 | AC | 60 ms
51,560 KB |
testcase_19 | AC | 88 ms
53,184 KB |
testcase_20 | AC | 85 ms
53,424 KB |
testcase_21 | AC | 88 ms
53,168 KB |
testcase_22 | AC | 90 ms
55,396 KB |
testcase_23 | AC | 96 ms
55,460 KB |
testcase_24 | AC | 95 ms
55,468 KB |
testcase_25 | AC | 95 ms
55,624 KB |
ソースコード
import java.io.*; import java.util.*; public class Main { static final int MOD = 998244353; public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); boolean[] isNotPrime = new boolean[n + 1]; int[] numbers = new int[n + 1]; int max = 0; for (int i = 2; i <= n; i++) { numbers[i] = i; if (isNotPrime[i]) { continue; } max = i; for (int j = 2; j * i <= n; j++) { isNotPrime[j * i] = true; } } long ans = 1; for (int i = 2; i <= n; i++) { if (i == max) { continue; } if (numbers[i] <= 1) { continue; } ans *= numbers[i]; ans %= MOD; for (int j = 2; j * i <= n; j++) { numbers[j * i] /= numbers[i]; } } System.out.println(ans); } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public double nextDouble() throws Exception { return Double.parseDouble(next()); } public String next() throws Exception { if (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }