結果

問題 No.260 世界のなんとか3
ユーザー 37zigen37zigen
提出日時 2016-08-25 17:31:20
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,579 bytes
コンパイル時間 3,427 ms
コンパイル使用メモリ 77,536 KB
実行使用メモリ 64,044 KB
最終ジャッジ日時 2024-04-25 15:21:30
合計ジャッジ時間 12,978 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 MLE -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

package No200番台;

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

public class Q260 {
	public static void main(String[] args) {
		new Q260().solver();
	}

	long MOD = 1_000_000_000 + 7;

	// 3の倍数⇔各位の数字の和が3で割り切れる。
	// 3のつく数→DPで探す?
	// 上を満たし、下を満たさない数の数を数える。
	// 8の倍数⇔下3けたが8の倍数

	void solver() {
		Scanner sc = new Scanner(System.in);
		BigInteger A = new BigInteger(sc.next());
		BigInteger B = new BigInteger(sc.next());
		BigInteger ans = BigInteger.ZERO;
		ans = A.divide(BigInteger.valueOf(3));

		// dp[fool][mod_3][eqA][eqB][digits]
		// Aと比べて eqA->0:小さい 1:等しい 2:大きい
		// Bと比べてeqB->0:小さい 1:等しい 2:大きい
		// mod_3->各桁の数の和のmodulo3
		// fool-> 0:3が付いている 1:3が付いていない
		// digits :何桁目か
		long[][][][][] dp = new long[2][3][3][3][10001];
		for (int i = 0; i < 10000; i++) {
			if (i % 8 == 0)
				continue;
			int digits = 0;
			int tmp = i;
			boolean fool = false;
			while (tmp > 0) {
				if (tmp % 10 == 3) {
					fool = true;
				}
				tmp /= 10;
				digits++;
			}
			if (fool) {
				int eqA = A.divide(BigInteger.valueOf((long) Math.pow(10, digits))).compareTo(BigInteger.valueOf(i))
						+ 1;
				int eqB = B.divide(BigInteger.valueOf((long) Math.pow(10, digits))).compareTo(BigInteger.valueOf(i))
						+ 1;
				dp[1][i % 3][eqA][eqB][digits]++;
			}
		}
	}

//	long dfs(int digits_number,int MOD_3){
//		if(digits_number>3)
//	}
}
0