結果

問題 No.250 atetubouのzetubou
ユーザー yukirinyukirin
提出日時 2016-03-02 19:07:54
言語 Go
(1.22.1)
結果
AC  
実行時間 19 ms / 5,000 ms
コード長 769 bytes
コンパイル時間 10,916 ms
コンパイル使用メモリ 239,984 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-19 06:37:37
合計ジャッジ時間 12,021 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
6,812 KB
testcase_01 AC 3 ms
6,816 KB
testcase_02 AC 15 ms
6,944 KB
testcase_03 AC 18 ms
6,940 KB
testcase_04 AC 15 ms
6,944 KB
testcase_05 AC 16 ms
6,940 KB
testcase_06 AC 13 ms
6,944 KB
testcase_07 AC 7 ms
6,944 KB
testcase_08 AC 15 ms
6,940 KB
testcase_09 AC 12 ms
6,940 KB
testcase_10 AC 17 ms
6,940 KB
testcase_11 AC 11 ms
6,940 KB
testcase_12 AC 15 ms
6,940 KB
testcase_13 AC 9 ms
6,940 KB
testcase_14 AC 2 ms
6,944 KB
testcase_15 AC 19 ms
6,940 KB
testcase_16 AC 19 ms
6,940 KB
testcase_17 AC 18 ms
6,940 KB
testcase_18 AC 19 ms
6,940 KB
testcase_19 AC 18 ms
6,944 KB
testcase_20 AC 1 ms
6,940 KB
testcase_21 AC 2 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func main() {
	sc.Split(bufio.ScanWords)
	q := nextInt()
	for i := 0; i < q; i++ {
		d, x, t := nextInt(), nextInt(), nextInt()
		if ncr(d+x-1, x, t) {
			fmt.Println("AC")
			continue
		}
		fmt.Println("ZETUBOU")
	}
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(nextLine())
	return i
}

func ncr(n, r, t int) bool {
	if n < 0 || r < 0 || r > n {
		return false
	}

	k := r
	if k > n/2 {
		k = n - r
	}

	ret := int(1)
	for i := int(1); i <= k; i++ {
		ret *= n - i + 1
		ret /= i

		if ret > t {
			return false
		}
	}
	if ret > t {
		return false
	}
	return true
}
0