結果

問題 No.1220 yukipoker
ユーザー 👑 hos.lyrichos.lyric
提出日時 2020-09-04 21:55:05
言語 D
(dmd 2.106.1)
結果
AC  
実行時間 119 ms / 2,000 ms
コード長 1,932 bytes
コンパイル時間 776 ms
コンパイル使用メモリ 106,616 KB
実行使用メモリ 11,268 KB
最終ジャッジ日時 2023-09-04 09:47:46
合計ジャッジ時間 4,198 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
6,916 KB
testcase_01 AC 9 ms
6,784 KB
testcase_02 AC 9 ms
6,216 KB
testcase_03 AC 9 ms
7,348 KB
testcase_04 AC 10 ms
6,464 KB
testcase_05 AC 8 ms
7,308 KB
testcase_06 AC 9 ms
6,712 KB
testcase_07 AC 9 ms
6,124 KB
testcase_08 AC 9 ms
7,608 KB
testcase_09 AC 8 ms
7,196 KB
testcase_10 AC 9 ms
6,436 KB
testcase_11 AC 58 ms
10,360 KB
testcase_12 AC 63 ms
10,028 KB
testcase_13 AC 117 ms
10,116 KB
testcase_14 AC 113 ms
10,620 KB
testcase_15 AC 77 ms
10,880 KB
testcase_16 AC 87 ms
11,052 KB
testcase_17 AC 54 ms
10,080 KB
testcase_18 AC 67 ms
11,068 KB
testcase_19 AC 119 ms
10,948 KB
testcase_20 AC 119 ms
11,268 KB
testcase_21 AC 9 ms
6,732 KB
testcase_22 AC 9 ms
6,408 KB
testcase_23 AC 9 ms
6,572 KB
testcase_24 AC 9 ms
6,192 KB
testcase_25 AC 8 ms
6,464 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.conv, std.functional, std.range, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.bitmanip, std.complex, std.container, std.math, std.mathspecial, std.numeric, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }


enum LIM = 2 * 10^^5 + 10;

void main() {
  auto logFac = new real[LIM];
  logFac[0] = 0.0L;
  foreach (i; 1 .. LIM) {
    logFac[i] = logFac[i - 1] + log(cast(real)(i));
  }
  
  try {
    for (; ; ) {
      const numCases = readInt();
      foreach (caseId; 0 .. numCases) {
        const N = readInt();
        const M = readInt();
        const K = readInt();
        
        /*
          M binom(N, K)
          (N - K + 1) M^K
        */
        const f = log(cast(real)(M)) + (logFac[N] - logFac[K] - logFac[N - K]);
        const s = log(cast(real)(N - K + 1)) + K * log(cast(real)(M));
        debug {
          writeln(exp(f), " ", exp(s));
        }
        writeln((f < s) ? "Flush" : "Straight");
      }
    }
  } catch (EOFException e) {
  }
}
0