結果

問題 No.1004 サイコロの実装 (2)
ユーザー ks2mks2m
提出日時 2020-03-06 22:43:34
言語 Java21
(openjdk 21)
結果
AC  
実行時間 138 ms / 2,000 ms
コード長 720 bytes
コンパイル時間 2,151 ms
コンパイル使用メモリ 79,152 KB
実行使用メモリ 41,612 KB
最終ジャッジ日時 2024-04-22 09:56:31
合計ジャッジ時間 8,556 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 131 ms
41,488 KB
testcase_01 AC 129 ms
41,536 KB
testcase_02 AC 127 ms
41,228 KB
testcase_03 AC 120 ms
40,092 KB
testcase_04 AC 131 ms
41,248 KB
testcase_05 AC 129 ms
41,468 KB
testcase_06 AC 117 ms
40,660 KB
testcase_07 AC 130 ms
41,424 KB
testcase_08 AC 128 ms
41,280 KB
testcase_09 AC 135 ms
41,220 KB
testcase_10 AC 138 ms
41,268 KB
testcase_11 AC 125 ms
40,112 KB
testcase_12 AC 121 ms
40,440 KB
testcase_13 AC 121 ms
40,380 KB
testcase_14 AC 130 ms
41,484 KB
testcase_15 AC 119 ms
40,080 KB
testcase_16 AC 118 ms
40,312 KB
testcase_17 AC 120 ms
40,132 KB
testcase_18 AC 131 ms
41,536 KB
testcase_19 AC 128 ms
41,524 KB
testcase_20 AC 122 ms
40,276 KB
testcase_21 AC 132 ms
41,164 KB
testcase_22 AC 132 ms
41,532 KB
testcase_23 AC 129 ms
41,256 KB
testcase_24 AC 132 ms
41,196 KB
testcase_25 AC 136 ms
41,612 KB
testcase_26 AC 121 ms
40,404 KB
testcase_27 AC 131 ms
41,612 KB
testcase_28 AC 128 ms
41,244 KB
testcase_29 AC 131 ms
41,524 KB
testcase_30 AC 116 ms
40,404 KB
testcase_31 AC 131 ms
41,452 KB
testcase_32 AC 120 ms
40,340 KB
testcase_33 AC 133 ms
41,364 KB
testcase_34 AC 121 ms
40,316 KB
testcase_35 AC 132 ms
41,612 KB
testcase_36 AC 131 ms
41,536 KB
testcase_37 AC 128 ms
41,468 KB
testcase_38 AC 132 ms
41,400 KB
testcase_39 AC 134 ms
41,568 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.math.BigInteger;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long[] x = new long[7];
		x[0] = sc.nextLong();
		long n = sc.nextLong();
		sc.close();

		long m = 1L << 32;
		for (int i = 1; i < x.length; i++) {
			x[i] = toBI(a).multiply(toBI(x[i - 1])).mod(toBI(m)).longValue();
			x[i] += b;
			x[i] %= m;
		}
		for (int i = 1; i < x.length; i++) {
			x[i]++;
		}

		if (x[1] % 2 == 1) {
			System.out.println(n / 2 + " 0");
		} else {
			System.out.println("0 " + n / 2);
		}
	}

	static BigInteger toBI(long x) {
		return BigInteger.valueOf(x);
	}
}
0