結果
問題 | No.420 mod2漸化式 |
ユーザー | uafr_cs |
提出日時 | 2016-09-09 22:50:22 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 78 ms / 1,000 ms |
コード長 | 2,317 bytes |
コンパイル時間 | 3,523 ms |
コンパイル使用メモリ | 80,204 KB |
実行使用メモリ | 52,680 KB |
最終ジャッジ日時 | 2024-06-06 18:06:36 |
合計ジャッジ時間 | 7,150 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 70 ms
51,324 KB |
testcase_01 | AC | 72 ms
51,228 KB |
testcase_02 | AC | 76 ms
51,160 KB |
testcase_03 | AC | 69 ms
51,108 KB |
testcase_04 | AC | 70 ms
51,220 KB |
testcase_05 | AC | 68 ms
51,216 KB |
testcase_06 | AC | 68 ms
51,188 KB |
testcase_07 | AC | 69 ms
51,504 KB |
testcase_08 | AC | 70 ms
51,092 KB |
testcase_09 | AC | 70 ms
51,292 KB |
testcase_10 | AC | 75 ms
51,220 KB |
testcase_11 | AC | 71 ms
51,328 KB |
testcase_12 | AC | 73 ms
51,224 KB |
testcase_13 | AC | 71 ms
51,160 KB |
testcase_14 | AC | 73 ms
50,900 KB |
testcase_15 | AC | 75 ms
50,988 KB |
testcase_16 | AC | 70 ms
51,140 KB |
testcase_17 | AC | 74 ms
51,552 KB |
testcase_18 | AC | 78 ms
52,680 KB |
testcase_19 | AC | 75 ms
51,200 KB |
testcase_20 | AC | 72 ms
51,508 KB |
testcase_21 | AC | 72 ms
50,956 KB |
testcase_22 | AC | 76 ms
51,320 KB |
testcase_23 | AC | 73 ms
50,972 KB |
testcase_24 | AC | 73 ms
51,328 KB |
testcase_25 | AC | 73 ms
51,476 KB |
testcase_26 | AC | 73 ms
51,288 KB |
testcase_27 | AC | 74 ms
51,296 KB |
testcase_28 | AC | 69 ms
50,952 KB |
testcase_29 | AC | 72 ms
51,312 KB |
testcase_30 | AC | 71 ms
51,044 KB |
testcase_31 | AC | 72 ms
51,136 KB |
testcase_32 | AC | 70 ms
51,284 KB |
testcase_33 | AC | 51 ms
50,444 KB |
testcase_34 | AC | 48 ms
50,384 KB |
testcase_35 | AC | 49 ms
50,224 KB |
ソースコード
import java.io.BufferedReader; import java.io.Closeable; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; import java.util.LinkedList; import java.util.Scanner; import java.util.Set; import java.util.StringTokenizer; public class Main { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); final int x = sc.nextInt(); if(x >= 32){ System.out.println(0 + " " + 0); }else{ long[] count_DP = new long[32 + 1]; long[] count_nextDP = new long[32 + 1]; long[] value_DP = new long[32 + 1]; long[] value_nextDP = new long[32 + 1]; count_DP[0] = 1; for(int i = 0; i <= 31; i++){ Arrays.fill(count_nextDP, 0); Arrays.fill(value_nextDP, 0); //System.out.println(Arrays.toString(value_DP)); for(int j = 0; j <= i; j++){ count_nextDP[j] += count_DP[j]; if(j < 32){ count_nextDP[j + 1] += count_DP[j]; } value_nextDP[j] += value_DP[j] * 2; if(j < 32){ value_nextDP[j + 1] += value_DP[j] * 2 + count_DP[j]; } } { long[] tmp = count_DP; count_DP = count_nextDP; count_nextDP = tmp; } { long[] tmp = value_DP; value_DP = value_nextDP; value_nextDP = tmp; } } System.out.println(count_nextDP[x] + " " + value_nextDP[x]); } } public static class Scanner implements Closeable { private BufferedReader br; private StringTokenizer tok; public Scanner(InputStream is) throws IOException { br = new BufferedReader(new InputStreamReader(is)); } private void getLine() throws IOException { while (!hasNext()) { tok = new StringTokenizer(br.readLine()); } } private boolean hasNext() { return tok != null && tok.hasMoreTokens(); } public String next() throws IOException { getLine(); return tok.nextToken(); } public int nextInt() throws IOException { return Integer.parseInt(next()); } public long nextLong() throws IOException { return Long.parseLong(next()); } public double nextDouble() throws IOException { return Double.parseDouble(next()); } public void close() throws IOException { br.close(); } } }