結果
問題 | No.1885 Flat Permutation |
ユーザー | tenten |
提出日時 | 2023-01-17 19:11:55 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 62 ms / 2,000 ms |
コード長 | 2,299 bytes |
コンパイル時間 | 2,780 ms |
コンパイル使用メモリ | 86,544 KB |
実行使用メモリ | 51,352 KB |
最終ジャッジ日時 | 2025-01-02 20:45:04 |
合計ジャッジ時間 | 6,919 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 52 ms
51,280 KB |
testcase_01 | AC | 52 ms
51,068 KB |
testcase_02 | AC | 52 ms
50,924 KB |
testcase_03 | AC | 52 ms
51,072 KB |
testcase_04 | AC | 53 ms
51,076 KB |
testcase_05 | AC | 51 ms
51,132 KB |
testcase_06 | AC | 52 ms
51,312 KB |
testcase_07 | AC | 52 ms
51,208 KB |
testcase_08 | AC | 54 ms
51,192 KB |
testcase_09 | AC | 54 ms
50,964 KB |
testcase_10 | AC | 51 ms
51,204 KB |
testcase_11 | AC | 50 ms
51,060 KB |
testcase_12 | AC | 52 ms
51,156 KB |
testcase_13 | AC | 51 ms
51,076 KB |
testcase_14 | AC | 52 ms
50,924 KB |
testcase_15 | AC | 49 ms
51,164 KB |
testcase_16 | AC | 50 ms
51,120 KB |
testcase_17 | AC | 52 ms
51,224 KB |
testcase_18 | AC | 55 ms
51,204 KB |
testcase_19 | AC | 57 ms
51,156 KB |
testcase_20 | AC | 56 ms
50,944 KB |
testcase_21 | AC | 59 ms
51,208 KB |
testcase_22 | AC | 62 ms
51,328 KB |
testcase_23 | AC | 52 ms
50,904 KB |
testcase_24 | AC | 54 ms
49,772 KB |
testcase_25 | AC | 51 ms
51,200 KB |
testcase_26 | AC | 53 ms
51,148 KB |
testcase_27 | AC | 57 ms
51,200 KB |
testcase_28 | AC | 60 ms
51,112 KB |
testcase_29 | AC | 56 ms
50,892 KB |
testcase_30 | AC | 60 ms
51,072 KB |
testcase_31 | AC | 61 ms
51,076 KB |
testcase_32 | AC | 52 ms
51,172 KB |
testcase_33 | AC | 55 ms
51,120 KB |
testcase_34 | AC | 55 ms
51,160 KB |
testcase_35 | AC | 58 ms
51,152 KB |
testcase_36 | AC | 59 ms
51,164 KB |
testcase_37 | AC | 52 ms
51,328 KB |
testcase_38 | AC | 50 ms
51,208 KB |
testcase_39 | AC | 51 ms
50,928 KB |
testcase_40 | AC | 53 ms
51,144 KB |
testcase_41 | AC | 55 ms
51,352 KB |
testcase_42 | AC | 54 ms
51,304 KB |
testcase_43 | AC | 58 ms
51,200 KB |
testcase_44 | AC | 57 ms
51,076 KB |
testcase_45 | AC | 58 ms
50,888 KB |
testcase_46 | AC | 60 ms
51,024 KB |
ソースコード
import java.io.*; import java.util.*; import java.util.stream.*; public class Main { static final int MOD = 998244353; public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); int x = sc.nextInt(); int y = sc.nextInt(); int min = Math.min(x, y); int max = Math.max(x, y); int start; if (min == 1) { start = 1; } else { start = min + 1; } int goal; if (max == n) { goal = n; } else { goal = max - 1; } if (goal < start) { System.out.println(0); return; } if (goal - start < 3) { System.out.println(1); return; } int[] dp = new int[goal - start + 1]; dp[0] = 1; dp[1] = 1; dp[2] = 1; for (int i = 3; i < dp.length; i++) { dp[i] = (dp[i - 1] + dp[i - 3]) % MOD; } System.out.println(dp[dp.length - 1]); } } class Utilities { static String arrayToLineString(Object[] arr) { return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n")); } static String arrayToLineString(int[] arr) { return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new)); } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); StringBuilder sb = new StringBuilder(); 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 int[] nextIntArray() throws Exception { return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray(); } public String next() throws Exception { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }