結果

問題 No.250 atetubouのzetubou
ユーザー GrenacheGrenache
提出日時 2015-07-24 23:46:49
言語 Java19
(openjdk 21)
結果
AC  
実行時間 2,141 ms / 5,000 ms
コード長 2,338 bytes
コンパイル時間 4,154 ms
コンパイル使用メモリ 74,932 KB
実行使用メモリ 117,436 KB
最終ジャッジ日時 2023-09-22 23:57:00
合計ジャッジ時間 29,082 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,439 ms
115,664 KB
testcase_01 AC 346 ms
108,168 KB
testcase_02 AC 1,940 ms
115,932 KB
testcase_03 AC 2,141 ms
117,436 KB
testcase_04 AC 1,915 ms
116,268 KB
testcase_05 AC 1,944 ms
115,924 KB
testcase_06 AC 1,610 ms
115,864 KB
testcase_07 AC 838 ms
111,964 KB
testcase_08 AC 1,858 ms
115,876 KB
testcase_09 AC 1,490 ms
115,740 KB
testcase_10 AC 1,958 ms
115,932 KB
testcase_11 AC 1,178 ms
113,476 KB
testcase_12 AC 1,835 ms
116,032 KB
testcase_13 AC 1,033 ms
111,696 KB
testcase_14 AC 98 ms
87,264 KB
testcase_15 AC 278 ms
94,368 KB
testcase_16 AC 276 ms
94,880 KB
testcase_17 AC 284 ms
92,156 KB
testcase_18 AC 284 ms
94,632 KB
testcase_19 AC 284 ms
94,816 KB
testcase_20 AC 77 ms
82,932 KB
testcase_21 AC 74 ms
82,916 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Iterator;


public class Main_yukicoder250 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        preCombiLong(3000);
    	int q = sc.nextInt();
        for (int i = 0; i < q; i++) {
        	int d = sc.nextInt();
        	int x = sc.nextInt();
        	long t = sc.nextLong();

        	try {
        		if (combinationLong(x + d - 1, x) <= t) {
        			System.out.println("AC");
        		} else {
        			System.out.println("ZETUBOU");
        		}
        	} catch (RuntimeException e) {
        		System.out.println("ZETUBOU");
        	}
        }

        sc.close();
    }

	private static long[][] cacheLong;

	private static void preCombiLong(int size) {
		// cache size need size * size * 4.
		// size : ~3000
		cacheLong = new long[size + 1][];
		for (int i = 0; i <= size; i++) {
			cacheLong[i] = new long[i + 1];
			cacheLong[i][0] = 1;
			cacheLong[i][i] = 1;
		}
	}

	private static long combinationLong(int n, int r) {
		r = Math.min(n - r, r);

		if (cacheLong[n][r] == 0) {
			cacheLong[n][r] = combinationLong(n - 1, r) + combinationLong(n - 1, r - 1);
		}

		if (cacheLong[n][r] < 0) {
			throw new RuntimeException("Long Overflow!");
		}
		
		return cacheLong[n][r];
	}

	@SuppressWarnings("unused")
	private static class Scanner {
		BufferedReader br;
		Iterator<String> it;
		
		Scanner (InputStream in) {
			br = new BufferedReader(new InputStreamReader(in));
		}
		
		String next() throws RuntimeException  {
			try {
				if (it == null || !it.hasNext()) {
					it = Arrays.asList(br.readLine().split(" ")).iterator();
				}
				return it.next();
			} catch (IOException e) {
				throw new IllegalStateException();
			}
		}
		
		int nextInt() throws RuntimeException {
			return Integer.parseInt(next());
		}

		long nextLong() throws RuntimeException {
			return Long.parseLong(next());
		}

		float nextFloat() throws RuntimeException {
			return Float.parseFloat(next());
		}

		double nextDouble() throws RuntimeException {
			return Double.parseDouble(next());
		}

		void close() {
			try {
				br.close();
			} catch (IOException e) {
//				throw new IllegalStateException();
			}
		}
	}
}
0