結果
問題 |
No.411 昇順昇順ソート
|
ユーザー |
![]() |
提出日時 | 2016-08-12 22:55:13 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 938 bytes |
コンパイル時間 | 998 ms |
コンパイル使用メモリ | 105,088 KB |
実行使用メモリ | 19,328 KB |
最終ジャッジ日時 | 2024-11-07 15:40:39 |
合計ジャッジ時間 | 3,264 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 27 WA * 3 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; using System.Collections.Generic; using System.Linq; class Program { static string ReadLine() { return Console.ReadLine(); } static int ReadInt() { return int.Parse(ReadLine()); } static int[] ReadInts() { return ReadLine().Split().Select(int.Parse).ToArray(); } static string[] ReadStrings() { return ReadLine().Split(); } static long Combination(int n, int r) { long num = 1; long den = 1; for (int i = 0; i < r; i++) { num *= n - i; den *= r - i; } return num / den; } static long Calc(int n, int k) { if (k == 1) return 0; long sum = 0; int p = n - k; for (int i = 0; i <= p; i++) { sum += Combination(p, i); } return sum; } static void Main() { var xs = ReadInts(); int n = xs[0], k = xs[1]; Console.WriteLine(Calc(n, k)); } }