結果
問題 | No.389 ロジックパズルの組み合わせ |
ユーザー | むらため |
提出日時 | 2019-01-27 18:37:58 |
言語 | Nim (2.0.2) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 2,078 bytes |
コンパイル時間 | 3,420 ms |
コンパイル使用メモリ | 65,804 KB |
実行使用メモリ | 30,244 KB |
最終ジャッジ日時 | 2024-07-01 11:02:52 |
合計ジャッジ時間 | 6,610 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
6,812 KB |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | AC | 1 ms
6,944 KB |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | AC | 16 ms
6,940 KB |
testcase_10 | AC | 12 ms
6,940 KB |
testcase_11 | AC | 23 ms
6,944 KB |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | AC | 11 ms
6,940 KB |
testcase_15 | AC | 9 ms
6,944 KB |
testcase_16 | AC | 12 ms
6,944 KB |
testcase_17 | AC | 20 ms
6,940 KB |
testcase_18 | WA | - |
testcase_19 | AC | 2 ms
6,940 KB |
testcase_20 | AC | 1 ms
6,940 KB |
testcase_21 | AC | 1 ms
6,940 KB |
testcase_22 | AC | 2 ms
6,940 KB |
testcase_23 | AC | 2 ms
6,944 KB |
testcase_24 | AC | 2 ms
6,940 KB |
testcase_25 | AC | 2 ms
6,940 KB |
testcase_26 | AC | 2 ms
6,940 KB |
testcase_27 | AC | 2 ms
6,944 KB |
testcase_28 | AC | 2 ms
6,940 KB |
testcase_29 | AC | 2 ms
6,940 KB |
testcase_30 | AC | 1 ms
6,944 KB |
testcase_31 | AC | 2 ms
6,944 KB |
testcase_32 | AC | 2 ms
6,944 KB |
testcase_33 | AC | 2 ms
6,940 KB |
testcase_34 | AC | 2 ms
6,944 KB |
testcase_35 | AC | 2 ms
6,944 KB |
testcase_36 | AC | 2 ms
6,940 KB |
testcase_37 | AC | 1 ms
6,940 KB |
testcase_38 | AC | 2 ms
6,940 KB |
testcase_39 | AC | 1 ms
6,940 KB |
testcase_40 | AC | 2 ms
6,940 KB |
testcase_41 | AC | 2 ms
6,940 KB |
testcase_42 | AC | 2 ms
6,940 KB |
testcase_43 | AC | 2 ms
6,944 KB |
testcase_44 | AC | 1 ms
6,944 KB |
testcase_45 | AC | 2 ms
6,940 KB |
testcase_46 | AC | 2 ms
6,940 KB |
testcase_47 | AC | 1 ms
6,944 KB |
testcase_48 | AC | 2 ms
6,940 KB |
testcase_49 | WA | - |
testcase_50 | WA | - |
testcase_51 | WA | - |
testcase_52 | WA | - |
testcase_53 | WA | - |
testcase_54 | WA | - |
testcase_55 | WA | - |
testcase_56 | WA | - |
testcase_57 | WA | - |
testcase_58 | WA | - |
testcase_59 | WA | - |
testcase_60 | WA | - |
testcase_61 | WA | - |
testcase_62 | WA | - |
testcase_63 | WA | - |
testcase_64 | WA | - |
testcase_65 | WA | - |
testcase_66 | WA | - |
testcase_67 | WA | - |
testcase_68 | WA | - |
testcase_69 | AC | 2 ms
6,944 KB |
testcase_70 | AC | 1 ms
6,940 KB |
testcase_71 | AC | 2 ms
6,944 KB |
testcase_72 | AC | 1 ms
6,940 KB |
testcase_73 | AC | 1 ms
6,944 KB |
testcase_74 | AC | 2 ms
6,940 KB |
testcase_75 | AC | 2 ms
6,940 KB |
testcase_76 | AC | 2 ms
6,940 KB |
testcase_77 | AC | 2 ms
6,940 KB |
testcase_78 | AC | 2 ms
6,940 KB |
testcase_79 | WA | - |
testcase_80 | WA | - |
testcase_81 | WA | - |
testcase_82 | WA | - |
testcase_83 | WA | - |
testcase_84 | WA | - |
testcase_85 | WA | - |
testcase_86 | WA | - |
testcase_87 | WA | - |
testcase_88 | WA | - |
testcase_89 | WA | - |
testcase_90 | WA | - |
testcase_91 | WA | - |
testcase_92 | WA | - |
testcase_93 | WA | - |
testcase_94 | WA | - |
testcase_95 | WA | - |
testcase_96 | WA | - |
testcase_97 | WA | - |
testcase_98 | WA | - |
ソースコード
import sequtils,algorithm,math,strutils template times*(n:int,body) = (for _ in 0..<n: body) template `max=`*(x,y) = x = max(x,y) template `min=`*(x,y) = x = min(x,y) template useModulo() = const MOD = 1_000_000_007 type ModInt = object v:int # 0~MODに収まる proc toModInt*(a:int) : ModInt = if a < -MOD : result.v = ((a mod MOD) + MOD) mod MOD elif a < 0 : result.v = a + MOD elif a >= MOD: result.v = a mod MOD else: result.v = a proc `+`*(a,b:ModInt) : ModInt = result.v = a.v + b.v if result.v >= MOD : result.v = result.v mod MOD proc `*`*(a,b:ModInt) : ModInt = result.v = a.v * b.v if result.v >= MOD : result.v = result.v mod MOD proc `^`*(a:ModInt,b:int) : ModInt = if b == 0 : return 1.toModInt() if b == 1 : return a let pow = a^(b div 2) if b mod 2 == 0 : return pow * pow return pow * pow * a proc `+`*(a:int,b:ModInt) : ModInt = a.toModInt() + b proc `+`*(a:ModInt,b:int) : ModInt = a + b.toModInt() proc `-`*(a:ModInt,b:int) : ModInt = a + (-b) proc `-`*(a,b:ModInt) : ModInt = a + (-b.v) proc `-`*(a:int,b:ModInt) : ModInt = a.toModInt() + (-b.v) proc `*`*(a:int,b:ModInt) : ModInt = a.toModInt() * b proc `*`*(a:ModInt,b:int) : ModInt = a * b.toModInt() proc `/`*(a,b:ModInt) : ModInt = a * b^(MOD-2) proc `$`*(a:ModInt) : string = $a.v proc combination(n,k:int) : ModInt = # nCk を剰余ありで result = 1.toModInt() let x = k.max(n - k) let y = k.min(n - k) for i in 1..y: var m = n+1-i result = result * m / i.toModInt() useModulo() proc getchar_unlocked():char {. importc:"getchar_unlocked",header: "<stdio.h>" .} proc scan(): int = while true: let k = getchar_unlocked() if k < '0': break result = 10 * result + k.ord - '0'.ord let m = scan() let H = stdin.readLine().split().map(parseInt) if H.len == 1 : if H[0] == 0: quit "1",0 let n = m - (H.sum() - H.len) let h = H.len() let k = n - (h + h - 1) if k < 0: quit "NA",0 if k == 0 : quit "1",0 # h箇所にk個入れる組み合わせ echo (h+k).combination(h)