結果
問題 | No.688 E869120 and Constructing Array 2 |
ユーザー | AreTrash |
提出日時 | 2018-05-19 02:41:45 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 27 ms / 1,000 ms |
コード長 | 3,523 bytes |
コンパイル時間 | 924 ms |
コンパイル使用メモリ | 107,904 KB |
実行使用メモリ | 19,200 KB |
最終ジャッジ日時 | 2024-07-07 13:46:10 |
合計ジャッジ時間 | 2,076 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 23 ms
19,200 KB |
testcase_01 | AC | 26 ms
19,072 KB |
testcase_02 | AC | 27 ms
18,816 KB |
testcase_03 | AC | 26 ms
18,816 KB |
testcase_04 | AC | 25 ms
18,816 KB |
testcase_05 | AC | 24 ms
18,944 KB |
testcase_06 | AC | 24 ms
18,944 KB |
testcase_07 | AC | 26 ms
19,072 KB |
testcase_08 | AC | 25 ms
18,944 KB |
testcase_09 | AC | 22 ms
18,176 KB |
testcase_10 | AC | 24 ms
18,816 KB |
testcase_11 | AC | 25 ms
18,688 KB |
testcase_12 | AC | 24 ms
18,944 KB |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; using System.Linq; namespace No688 { public class Program { public static void Main(string[] args) { var K = long.Parse(Console.ReadLine()); if (K == 0) { Console.WriteLine("1"); Console.WriteLine("1"); } var comb = new Combination(100); for (var i = 2; i <= 30; i++) for (var j = 0; j <= 30 - i; j++) { if (K != comb.NCK(i, 2).Value * (1L << j)) continue; Console.WriteLine(i + j); Console.WriteLine(string.Join(" ", Enumerable.Repeat(1, i).Concat(Enumerable.Repeat(0, j)))); return; } } } public struct ModInt { public static int Mod = 1000000007; readonly long value; public int Value { get { return (int)value; } } public ModInt Inverse { get { return GetInverse(); } } public ModInt(long value) { value %= Mod; this.value = value < 0 ? value + Mod : value; } ModInt GetInverse() { if (value == 0) throw new InvalidOperationException("value must NOT equal 0"); return Pow(Mod - 2); } public ModInt Square() { return this * this; } public ModInt Pow(long exp) { if (exp == 0) return 1; if (exp % 2 == 0) return Pow(exp / 2).Square(); return this * Pow(exp - 1); } public static ModInt Parse(string str) { return long.Parse(str); } public static implicit operator ModInt(long value) { return new ModInt(value); } public static ModInt operator +(ModInt left, ModInt right) { return left.value + right.value; } public static ModInt operator -(ModInt left, ModInt right) { return left.value - right.value; } public static ModInt operator *(ModInt left, ModInt right) { return left.value * right.value; } public static ModInt operator /(ModInt left, ModInt right) { return left * right.Inverse; } public override bool Equals(object obj) { if (!(obj is ModInt)) return false; return value == ((ModInt)obj).value; } public override int GetHashCode() { return value.GetHashCode(); } public override string ToString() { return value.ToString(); } } public class Combination { readonly ModInt[] facts; public Combination(int max) { facts = new ModInt[max + 1]; facts[0] = 1; for (var i = 1; i <= max; i++) facts[i] = facts[i - 1] * i; } public ModInt Fact(int n) { return facts[n]; } public ModInt NCK(int n, int k) { if (n < k) return 0; return facts[n] / facts[k] / facts[n - k]; } public ModInt NPK(int n, int k) { if (n < k) return 0; return facts[n] / facts[n - k]; } public ModInt NHK(int n, int k) { if (k == 0) return 1; if (n == 0) return 0; return facts[n + k - 1] / facts[k] / facts[n - 1]; } } }