結果

問題 No.420 mod2漸化式
ユーザー uafr_csuafr_cs
提出日時 2016-09-09 22:50:22
言語 Java21
(openjdk 21)
結果
AC  
実行時間 87 ms / 1,000 ms
コード長 2,317 bytes
コンパイル時間 2,289 ms
コンパイル使用メモリ 76,936 KB
実行使用メモリ 52,936 KB
最終ジャッジ日時 2023-08-25 23:17:23
合計ジャッジ時間 6,583 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
52,492 KB
testcase_01 AC 86 ms
52,116 KB
testcase_02 AC 78 ms
52,048 KB
testcase_03 AC 77 ms
50,932 KB
testcase_04 AC 79 ms
52,624 KB
testcase_05 AC 78 ms
52,556 KB
testcase_06 AC 85 ms
51,884 KB
testcase_07 AC 77 ms
52,620 KB
testcase_08 AC 87 ms
52,508 KB
testcase_09 AC 77 ms
52,508 KB
testcase_10 AC 75 ms
50,704 KB
testcase_11 AC 78 ms
52,772 KB
testcase_12 AC 87 ms
52,380 KB
testcase_13 AC 78 ms
52,504 KB
testcase_14 AC 76 ms
52,496 KB
testcase_15 AC 80 ms
52,432 KB
testcase_16 AC 73 ms
50,920 KB
testcase_17 AC 78 ms
52,372 KB
testcase_18 AC 74 ms
52,936 KB
testcase_19 AC 86 ms
52,244 KB
testcase_20 AC 76 ms
51,116 KB
testcase_21 AC 74 ms
52,108 KB
testcase_22 AC 76 ms
52,552 KB
testcase_23 AC 78 ms
52,528 KB
testcase_24 AC 73 ms
51,664 KB
testcase_25 AC 76 ms
52,344 KB
testcase_26 AC 76 ms
52,560 KB
testcase_27 AC 73 ms
50,728 KB
testcase_28 AC 78 ms
52,216 KB
testcase_29 AC 82 ms
52,880 KB
testcase_30 AC 81 ms
52,760 KB
testcase_31 AC 74 ms
52,348 KB
testcase_32 AC 77 ms
52,484 KB
testcase_33 AC 43 ms
49,552 KB
testcase_34 AC 43 ms
49,264 KB
testcase_35 AC 44 ms
49,644 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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();
		}
	}
}
0